Thursday 4 September 2014

Get the current web page size of the screen and browser window


Properties:
screen.width screen.height screen.availWidth screen.availHeight screen.colorDepth screen.pixelDepth
If you are using jQuery, you can get the size of the window or the document using jQuery methods: $(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document $(window).width(); // returns width of browser viewport $(document).width(); // returns width of HTML document For screen size you can use the screen object in the following way: screen.height; screen.width;
A non-jQuery way to get the available screen dimension. window.screen.width/height has already been put up, but for responsive webdesign and completeness sake I think its worth to mention those attributes: alert(window.screen.availWidth); alert(window.screen.availHeight);