AlfieWebDevTips Homefor new and experienced developers
[Home Home] [Web Development Web Development ] [Code Generators Code Generators ] [Resources Resources ] [Contact Us Contact ] |WebDevTips Privacy Privacy |
Print This Page

You are here : Home - Resources - FAQ - Javascript Q1

FAQ - Javascript Q1



Q1:How can I get the document width and height?

A: Internet Explorer - use (document.body.clientWidth - document.body.clientHeight)

Mozilla - use (document.body.clientWidth - document.body.clientHeight) or (window.innerWidth - window.innerHeight)

Netscape 4x - use (window.innerWidth - window.innerHeight)
Netscape 6 - use (window.innerWidth - window.innerHeight)

Opera - use (window.innerWidth - window.innerHeight)

The best thing to do is object detect

//opera Netscape 6 Netscape 4x Mozilla 
if (window.innerWidth || window.innerHeight){ 
docwidth = window.innerWidth; 
docheight = window.innerHeight; 

//IE Mozilla 
if (document.body.clientWidth || document.body.clientHeight){ 
docwidth = document.body.clientWidth; 
docheight = document.body.clientHeight; 
}

Test It Here


back to faq




Google
 

[back to top of page]   

[labelled with icra -  - this link will open in a new window] [RSS Content]

[Copyright © WebDevTips]