IE中的currentStyle为null

Him*_*ack 3 javascript css internet-explorer

我正在尝试计算元素的当前样式:

function cssIsLoaded(c) {
    if (window.getComputedStyle) {
        return window.getComputedStyle(c, null).display === "none";
    }
    else if (c.currentStyle) {

    }

    return true;
}

(function() {
    var cssload = document.createElement("div");
    cssload.className = "_css_loaded";
    checkLoaded();

    function checkLoaded() {
        if (!cssIsLoaded(cssload)) setTimeout(function() {
            checkLoaded();
        }, 20);
        else blalbalblbalbalablbal();
    }
})();
Run Code Online (Sandbox Code Playgroud)

IE没有进入第二个条件,c.currentStyle是null ...为什么?

Tim*_*own 7

在将元素currentStyle添加到文档之前,元素不会填充其属性,这是有道理的:在将元素添加到文档之前,浏览器无法知道哪些现有样式规则将应用于它.