Window dimensions

admin

Administrator
Staff member
I need to know the dimensions of the navigator window. I use the classic technique :

if (window.innerWidth && typeof(window.innerWidth) == 'number') screenwidth = window.innerWidth;
else if (window.document.body && typeof(window.document.body.clientWidth) == 'number') screenwidth = window.document.body.clientWidth;

if (window.innerHeight && typeof(window.innerHeight) == 'number') screenheight = window.innerHeight;
else if (window.document.body && typeof(window.document.body.clientHeight) == 'number') screenheight = window.document.body.clientHeight;

But, screenHeight and screenWidth are both 0 in IE6. UNLESS, I repeat the code a second time and then I have the result I want.

Does window.document.body need to be initialized before use?? Why does it work the second time around?

NS6+ permits window.document.body.clientHeight and window.document.body.clientWidth too and I get the some results -- that is, I need to test a second time.

What's up? What am I doing wrong?

All the best, kiser
 
Back
Top