Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > FAQ Topic - How do I find the size of the window/browser canvas area? (2008-02-22)

Reply
Thread Tools

FAQ Topic - How do I find the size of the window/browser canvas area? (2008-02-22)

 
 
FAQ server
Guest
Posts: n/a
 
      02-22-2008
-----------------------------------------------------------------------
FAQ Topic - How do I find the size of the window/browser
canvas area?
-----------------------------------------------------------------------

While it is often asked about window size, what is more relevant is
the "canvas area" of the browser.

Where supported in NN: (>NN4.0)

var winWidth = window.innerWidth;
var winHeight = window.innerHeight;

Where supported in IE: (>IE4.0)

var winWidth = document.body.clientWidth;
var winHeight = document.body.clientHeight;

Where supported in modern browsers:

var winWidth = document.documentElement.clientWidth;
var winHeight = document.documentElement.clientHeight;

Where supported in DOM compliant browsers:

var winWidth, winHeight, d=document;
if (typeof window.innerWidth!='undefined') {
winWidth = window.innerWidth;
winHeight = window.innerHeight;
} else {
if (d.documentElement &&
typeof d.documentElement.clientWidth!='undefined' &&
d.documentElement.clientWidth!==0) {
winWidth = d.documentElement.clientWidth;
winHeight = d.documentElement.clientHeight;
} else {
if (d.body &&
typeof d.body.clientWidth!='undefined') {
winWidth = d.body.clientWidth;
winHeight = d.body.clientHeight;
}
}
}

Note: The dimensions can not be determined accurately until after the
document has finished loading.

http://msdn2.microsoft.com/en-us/library/ms533566.aspx

http://docs.sun.com/source/816-6408-...ow.htm#1202446

http://msdn2.microsoft.com/en-us/library/ms533024.aspx


--
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.pair.com.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ Topic - How do I find the size of the window/browser canvas area? FAQ server Javascript 1 08-19-2007 02:30 PM
FAQ Topic - How do I find the size of the window/browser canvas area? FAQ server Javascript 0 06-16-2007 11:00 PM
FAQ Topic - How do I find the size of the window/browser canvas area? FAQ server Javascript 0 04-16-2007 11:00 PM
FAQ Topic - How do I find the size of the window/browser canvas area? FAQ server Javascript 1 02-15-2007 02:30 AM
FAQ Topic - How do I find the size of the window/browser canvas area? FAQ server Javascript 4 12-16-2006 11:58 PM



Advertisments