This code works fine. Just tested it in a Windows ME window with IE6, returns "null" because IE6 does not support position:fixed; .
By the way, this is NOT originally my code. ALL credits go to Kangax Github , which has many functions for checking browser functions.
function () { var container = document.body; if (document.createElement && container && container.appendChild && container.removeChild) { var el = document.createElement("div"); if (!el.getBoundingClientRect) { return null; } el.innerHTML = "x"; el.style.cssText = "position:fixed;top:100px;"; container.appendChild(el); var originalHeight = container.style.height, originalScrollTop = container.scrollTop; container.style.height = "3000px"; container.scrollTop = 500; var elementTop = el.getBoundingClientRect().top; container.style.height = originalHeight; var isSupported = elementTop === 100; container.removeChild(el); container.scrollTop = originalScrollTop; return isSupported; } return null; }
If it starts, it works, and if not, you get zero.
Ohgodwhy
source share