سؤال

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