Created
May 23, 2019 08:39
-
-
Save AlexKardone/e255035b06a4ac6628baaa5c8e909d23 to your computer and use it in GitHub Desktop.
Get the document width/height
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ua = navigator.userAgent.toLowerCase(); | |
var isOpera = (ua.indexOf('opera') > -1); | |
var isIE = (!isOpera && ua.indexOf('msie') > -1); | |
function getDocumentHeight() { | |
return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight()); | |
} | |
function getViewportHeight() { | |
return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment