Check the viewport size

Window. InnerWidth/innerHeight -- -- IE8 and IE8 following incompatible

Document. The documentElement. ClientWidth/clientHeight - standard mode, are compatible with any browser <! doctype html>

Document. Body. ClientWidth/clientHeight - applies to strange mode of browser (i.e., remove (! doctype html)

Document.com patMode compatible. CSS1Compat in standard mode —-/BackCompat in backward compatible weird mode

Switch the Dock side to see the horizontal and vertical dimensions

/ / not equal horizontal scroll bar when the two Windows. The innerWidth = document. The documentElement. ClientWidth, but just not the same after combined with horizontal scroll bar

GetViewportOffset ()

      function getViewportOffset(){
          if(window.innerWidth){
              return{
                  w:window.innerWidth,
                  h:window.innerHeight
              }
          }else{
              if(document.compatMode == "BackMode"){
              return{
                  w:document.body.clientWidth,
                  h:document.body.clientHeight
              }
          }else{
              return{
                 w:document.documentElement.clientWidth,
                 h:document.documentElement.clientHeight 
              }
              }
          }
      }
Copy the code