Results 1 to 4 of 4

Thread: Can you use javascript to find the height of a window? *Resolved*

  1. #1
    New Member
    Join Date
    Jan 03
    Posts
    2

    Can you use javascript to find the height of a window? *Resolved*

    Hello,

    I am very new to javascript, so this is why I am asking a question that is probably very basic. I apologize for this...

    Anyway, I am writing a web page where I need to find the height of the window. How would I go about doing this? Is it possible to do this without opening a new window?

    Thank you very much for your assistance.
    Last edited by gertj; Jan 27th, 2003 at 09:01 PM.

  2. #2
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 02
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174
    Code:
    if (parseInt(navigator.appVersion)>3) {
     if (navigator.appName=="Netscape") {
      winW = window.innerWidth;
      winH = window.innerHeight;
     }
     if (navigator.appName.indexOf("Microsoft")!=-1) {
      winW = document.body.offsetWidth;
      winH = document.body.offsetHeight;
     }
    }
    
    document.write(
     "Window width = "+winW+"<br>"
    +"Window height = "+winH
    )
    To adjust the width and height values taking into accout the scrollbars in Netscape Navigator: subtract 16 from the width and height and in Microsoft Internet Explorer: subtract 20 from the width and height

    source

  3. #3
    New Member
    Join Date
    Jan 03
    Posts
    2

    Thanks

    Thanks for the help! I appreciate it very much.

  4. #4
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 02
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174
    YW

Posting Permissions

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