Update Panel .NET

Exploring Microsoft ASP.NET AJAX and jQuery

Archive for February 2009

Getting the page and viewport dimensions using jQuery

with 4 comments

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();

Written by tzkuei

February 20, 2009 at 5:11 pm

Posted in CSS, JavaScript, jQuery