SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot Marek Bereza's Avatar
    Join Date
    Sep 2001
    Location
    London
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Document width in JavaScript?

    How do I get the width of a document (the inner width of the window) with javascript? Can't use document.width because it only works in Netscape, and same with window.innerWidth
    Please help me! I don't really know what I'm doing with Javascript. All I know is that I have to use it to do what I want to do.
    of the brethren of disco metal
    Disco metal tunes at www.wikid.co.uk

  2. #2
    I am the night... bman's Avatar
    Join Date
    Mar 2001
    Location
    In a van... down by the river.
    Posts
    366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here ya go... i think this should work...
    Code:
    <script language="javascript">
    <!--//
    var width
    
    if(document.all)//for IE
    {
     width=document.body.clientWidth 
    }
    else if (document.layers) //for NS
    {
     width=window.innerWidth
    }
    //-->
    </script>
    Some say the world will end in fire, Some say in ice.
    From what I've tasted of desire
    I hold with those who favor fire.


Bookmarks

Posting Permissions

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