Domanda

I want retrieve the width and height of browser in pixel(px) using ruby code. I don't have any idea how to do this.

Please help

È stato utile?

Soluzione

With the help of Javascript you can calculate the width and height of browser and pass this info to server using AJAX .

Else not possible by ruby code .

EDITED :

If you are working on rails app than you can do it like :

To get the browser dimension use the link : http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

And if you using jQuery then use below function to get the height and width of window .

$(window).width();
$(window).height();

And use Ajax feature to pass this dimension to your action .

Altri suggerimenti

Server side language can't do that, you should use javascript to do such thing.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top