Skip to content

Instantly share code, notes, and snippets.

@DmitryMyadzelets
Last active August 29, 2015 14:21
Show Gist options
  • Save DmitryMyadzelets/bc2a0c08a654825943a4 to your computer and use it in GitHub Desktop.
Save DmitryMyadzelets/bc2a0c08a654825943a4 to your computer and use it in GitHub Desktop.
Some function for web page view analysis
// Returns entire web page height
function page_height () {
return Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
}
// Returns visible web page height
function view_height () {
return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}
// Returns ofsset of the visible web page from the top
function view_offset () {
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment