Frage

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

War es hilfreich?

Lösung

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 .

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top