How to get the size of screen window using jQuery?

By | 5th September 2019

you can get the size of the window or document using jQuery methods:

$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document (same as pageHeight in screenshot)
$(window).width(); // returns width of browser viewport
$(document).width(); // returns width of HTML document (same as pageWidth in screenshot)

A non-jQuery way to get the available screen dimension. For responsive webdesign and completeness sake I think its worth to mention those attributes:

alert(window.screen.availWidth);
alert(window.screen.availHeight);

Leave a Reply

Your e-mail address will not be published. Required fields are marked *