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

有帮助吗?

解决方案

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 .

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top