Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Getting Window Browser Size

Getting Window Browser Size

Scheduled Pinned Locked Moved Web Development
javascriptquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chaddolan
    wrote on last edited by
    #1

    Hello everyone, Is there a way to get the size of the browser window with javascript? Thanks, Chad

    Steve EcholsS H 2 Replies Last reply
    0
    • C chaddolan

      Hello everyone, Is there a way to get the size of the browser window with javascript? Thanks, Chad

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      Here are a couple of functions to get the client area: function clientHeight() { var myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function clientWidth() { var myWidth = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; } else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) { //IE 4 compatible myWidth = document.body.clientWidth; } return myWidth; } They seem to work in IE and FF. Can't remember where I got these from, somewhere on google is my bet...

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      C 1 Reply Last reply
      0
      • Steve EcholsS Steve Echols

        Here are a couple of functions to get the client area: function clientHeight() { var myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function clientWidth() { var myWidth = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; } else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) { //IE 4 compatible myWidth = document.body.clientWidth; } return myWidth; } They seem to work in IE and FF. Can't remember where I got these from, somewhere on google is my bet...

        C Offline
        C Offline
        chaddolan
        wrote on last edited by
        #3

        Thanks, I will try these. Chad

        1 Reply Last reply
        0
        • C chaddolan

          Hello everyone, Is there a way to get the size of the browser window with javascript? Thanks, Chad

          H Offline
          H Offline
          Hammad Arshad
          wrote on last edited by
          #4

          Try this: windowWidth = window.screen.width;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups