Skip to content

Instantly share code, notes, and snippets.

@hiro3
Created June 2, 2013 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiro3/5693272 to your computer and use it in GitHub Desktop.
Save hiro3/5693272 to your computer and use it in GitHub Desktop.
BackCompat = Back Compatible = 後方互換モードだとdocument.bodyをみないと値が取れないためrootを設定。
var root = (document.compatMode === "BackCompat") ? document.body : document.documentElement;
console.log([
root.clientHeight,//height of the visible area
root.clientWidth,//width of the visible area
root.scrollHeight,//document height including hidden(scroll) area
root.scrollWidth,//document width including hidden(scroll) area
window.pageYOffset || root.scrollTop,
window.pageXOffset || root.scrollLeft,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment