Tip: Click lines to highlight, hold ctrl/cmd to multi-select

Viewport (30-Dec @ 12:43)

remy

Syntax Highlighted Code

  1. function getViewportHeight() {
  2.     var height = self.innerHeight; // Safari, Opera
  3.     var mode = document.compatMode;
  4.  
  5.     if ( (mode || $.browser.msie) && !$.browser.opera ) { // IE, Gecko
  6.         height = (mode == 'CSS1Compat') ?
  7.         document.documentElement.clientHeight : // Standards
  8.         document.body.clientHeight; // Quirks
  9.     }
  10.    
  11.     return height;
  12. }
  13.  
  14. function getViewportWidth() {
  15.     var width = self.innerWidth; // Safari, Opera
  16.     var mode = document.compatMode;
  17.  
  18.     if ( (mode || $.browser.msie) && !$.browser.opera ) { // IE, Gecko
  19.         width = (mode == 'CSS1Compat') ?
  20.         document.documentElement.clientWidth : // Standards
  21.         document.body.clientWidth; // Quirks
  22.     }
  23.  
  24.     return width;
  25. }

Plain Code

function getViewportHeight() {
    var height = self.innerHeight; // Safari, Opera
    var mode = document.compatMode;

    if ( (mode || $.browser.msie) && !$.browser.opera ) { // IE, Gecko
        height = (mode == 'CSS1Compat') ?
        document.documentElement.clientHeight : // Standards
        document.body.clientHeight; // Quirks
    }
    
    return height;
}

function getViewportWidth() {
    var width = self.innerWidth; // Safari, Opera
    var mode = document.compatMode;

    if ( (mode || $.browser.msie) && !$.browser.opera ) { // IE, Gecko
        width = (mode == 'CSS1Compat') ?
        document.documentElement.clientWidth : // Standards
        document.body.clientWidth; // Quirks
    }

    return width;
}

Codedump Run

Permalink: http://codedumper.com/viewport