我正在尝试计算元素的当前样式:
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
属性,这是有道理的:在元素被添加到文档之前,浏览器无法知道哪些现有样式规则将被填充适用于它。
关于javascript - IE 中的 currentStyle 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4143326/