Snow_Fall

My Understanding of code snipet

Code snipet1

function set_width() { /*function to set the width around which the snow would fall*/
      var sw, sh; /*variables to store the height and width*/
      if (typeof(window.innerWidth)=='number' && window.innerWidth) {/*checking if the inner width of window is number and is true*/
	  sw=window.innerWidth;                               /*storing the inner width of window to the variable*/
          sh=window.innerHeight;                  /*storing the inner height of window to the variable*/
       }
      else if (document.compatMode=="CSS1Compat" && document.documentElement && document.documentElement.clientWidth) {
      sw=document.documentElement.clientWidth;
      sh=document.documentElement.clientHeight;
      }
      else {
      sw=document.body.clientWidth;    /* checking for IE and storing the width*/
      sh=document.body.clientHeight;  /*checking for IE and storing the height*/
          }

Exlanation:

The function adjusts the width of screen where snow would fall by checking the type of browser window.For Internet Explorer,Chrome,Firefox,Opera and Safari,window.innerHeight gives the inner height of the browser window and window.innerWidth gives the width of the browser window.For Internet Explorer 8,7,6,5 document.documentElement.clientHeight gives the height of the browser window and document.document.Element.clientWidth gives the browser window width.

References and links

JavaScript for Snowfall

w3schools