IE中的currentStyle为null [英] currentStyle in IE is null
本文介绍了IE中的currentStyle为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要计算当前样式的元素:
I am trying to caculate the current style of an element:
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
is null ...为什么?
IE doesnt get into the 2nd condition, c.currentStyle
is null... why is that?
推荐答案
元素不会得到它的 currentStyle
属性,直到它被添加到文档,这是有道理的:直到元素被添加到文档,浏览器不能知道哪些现有的样式规则将适用于它。
An element doesn't get its currentStyle
property populated until it's added to the document, which makes some sense: until the element's been added to the document, the browser cannot know which existing style rules will apply to it.
这篇关于IE中的currentStyle为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文