JS: Calculate Browser window Height

Calculating browser window size using Javascript is not straight forward. There are many properties to check for and each property behaves differently in each version of Browser.

Following are various properties available to get Browser window width and height:
  • window.innerHeight/window.innerWidth
  • window.outerheight/window.outerwidth
  • document.body.clientHeight/document.body.clientWidth
  • document.documentElement.clientHeight/document.documentElement.clientWidth
Now if you want to calculate the window width and height you'll have to write javascript that checks the browser type and gets the width and height.

Fortunately for us Mark has already written a script that works in any browser. Here it is... http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

Thank you Mark!

No comments: