Skip to content

Instantly share code, notes, and snippets.

@mattfarina
Created March 29, 2011 16:21
Show Gist options
  • Save mattfarina/892665 to your computer and use it in GitHub Desktop.
Save mattfarina/892665 to your computer and use it in GitHub Desktop.
$.support.positionFixed = (function () {
var el, support,
body = document.body || document.getElementsByTagName("body")[0] || document.documentElement;
// Boolean indicating whether or not "position: fixed" is supported.
// Using the DOM to create an element is much faster than using jQuery.
el = document.createElement("div");
el.style.position = "fixed";
el.style.top = "10px";
el.style.visibility = "hidden";
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
// This arises when a base node is used.
body.insertBefore(el, body.firstChild);
support = parseInt(el.offsetTop, 10) - (body.scrollTop ? body.scrollTop : 0) === 10;
body.removeChild(el);
return support;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment