Archive for February 2009
Getting the page and viewport dimensions using jQuery
To get the width and height of the whole page (document), use:
var pageWidth = $(document).width(); var pageHeight = $(document).height();
To get the width and height of the viewport (window), use:
var viewportWidth = $(window).width(); var viewportHeight = $(window).height();
With Opera 9.5, $(window).height() returns the document height, as documented here.
To fix it, use:
var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();