...

View Full Version : finding the width of the IE



frodo444
06-10-2003, 10:01 PM
I'm trying to find a property of either document or navigator or window that will tell me what the width of the window. I have already found two pretty handy one's for Netscape (innerHeight/Width) but IE seems to be more of a pain in the butt with these sort of things.
Thanks,
Eric

Garadon
06-10-2003, 10:11 PM
document.body.clientWidth;

screen.width;

screen.availWidth;

frodo444
06-10-2003, 10:26 PM
I get undefined when I try document.body.clientWidth in an alert box. ie alert(document.body.clientWidth). I know that screen.width is like 1024, because I have my resolution set to 1024x768. I'm not quite sure what the difference between width and availWidth is because I get 1024 each time. Hope this helps for response purposes.
Thanks, Eric

Garadon
06-10-2003, 10:38 PM
document.body.clientWidth


doesn't work if it is called before onLoad I think it is,
so
onload="alert(document.body.clientWidth);"
will work.


Note: I migth be wrong if I am I bet some1 will say so :)

screen.width shows the width of the screen.
screen.availWidth shows the availble width of screen.

if u put ur task bar to be aligned on the side of the sceen u will see the difference

frodo444
06-10-2003, 10:43 PM
I actually had it running in my onLoad function... wierd. I put a line in my body tag:

onLoad="adjustWidth();alert(document.body.clientWidth)"

I don't know why it wouldn't work inside the adjustWidth() function, which is actually where I need it. I guess I could make a dummy function that just calls the adjustWidth() one. I'll try that and report back.

Regards,
Eric

frodo444
06-10-2003, 10:47 PM
Thanks for your help Garadon, you pointed me in the right direction. I got it to work with a dummy function that just calls the function I actually want to call. I guess the onLoad event calls the set function before it sets some of the other variables. Thanks,

Eric

brothercake
06-10-2003, 11:28 PM
if you're working in IE6's "Standards Compliant" mode - for example, using an XHTML Strict doctype without an XML declaration - then document.body.clientWidth no longer returns a value.

The equivalent for that situation is document.documentElement.offsetWidth



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum