Are you new? Read the FAQ and catch up on!
171 views

Function to get window size

Javascript
  1. function getWindowSize()
  2. {
  3.     var winH, winW;
  4.     if (window.innerWidth)
  5.     {
  6.         winW = window.innerWidth;
  7.         winH = window.innerHeight;
  8.     }
  9.     else if (document.body && document.body.offsetWidth)
  10.     {
  11.         winW = document.body.offsetWidth;
  12.         winH = document.body.offsetHeight;
  13.     }
  14.     return { height: winH, width: winW };
  15. }
  16.  

­

Tags: JavaScript window size

Embed: