Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE中的currentStyle为空_Javascript_Css_Internet Explorer - Fatal编程技术网

Javascript IE中的currentStyle为空

Javascript IE中的currentStyle为空,javascript,css,internet-explorer,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.c

我试图计算元素的当前样式:

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();
    }
})();

IE未进入第二个条件,
c.currentStyle
为空。。。这是为什么?

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

您在哪里调用
cssIsLoaded()
?你通过的是什么元素?你能在创建一个例子吗?我正在传递一个我刚刚创建的DIV。在站点中加载函数的JS后,我调用该函数。(它是在我创建div之后调用的。请准确显示您是如何传递它的。这很可能是错误所在。