Skip to content

Instantly share code, notes, and snippets.

@AlexKardone
Created May 23, 2019 08:39
Show Gist options
  • Save AlexKardone/e255035b06a4ac6628baaa5c8e909d23 to your computer and use it in GitHub Desktop.
Save AlexKardone/e255035b06a4ac6628baaa5c8e909d23 to your computer and use it in GitHub Desktop.
Get the document width/height
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