Test It Here
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;
}