Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    finding the width of the IE

    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
    Last edited by frodo444; 06-10-2003 at 10:03 PM.

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    document.body.clientWidth;

    screen.width;

    screen.availWidth;

  • #3
    New Coder
    Join Date
    Jun 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    doesn't work.

    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

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    New Coder
    Join Date
    Jun 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    huh... funny

    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

  • #6
    New Coder
    Join Date
    Jun 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    okay, I got it

    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

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •