Skip to content

Instantly share code, notes, and snippets.

@adastreamer
Created May 14, 2016 16:29
Show Gist options
  • Save adastreamer/db92e8cd5d584a3ecc9710fa7c846b4b to your computer and use it in GitHub Desktop.
Save adastreamer/db92e8cd5d584a3ecc9710fa7c846b4b to your computer and use it in GitHub Desktop.
if ( jQuery.isWindow( elem ) ) {
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
var docElemProp = elem.document.documentElement[ "client" + name ],
body = elem.document.body;
return elem.document.compatMode === "CSS1Compat" && docElemProp ||
body && body[ "client" + name ] || docElemProp;
// Get document width or height
} else if ( elem.nodeType === 9 ) {
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
return Math.max(
elem.documentElement["client" + name],
elem.body["scroll" + name], elem.documentElement["scroll" + name],
elem.body["offset" + name], elem.documentElement["offset" + name]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment