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 doesnt get into the 2nd condition, c.currentStyle
is null... why is that?
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 doesnt get into the 2nd condition, c.currentStyle
is null... why is that?
-
1
Where are you calling
cssIsLoaded()
? What element are you passing? Can you create an example at jsfiddle? – Andy E Commented Nov 10, 2010 at 10:17 - I am passing a DIV I just created. i call the function once its JS is loaded in <head> in the site. (it is called right after i created that DIV – Himberjack Commented Nov 10, 2010 at 10:30
- please show exactly how you are passing it. That is most likely where the error is. – Pekka Commented Nov 10, 2010 at 10:31
1 Answer
Reset to default 7An 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745091710a4610731.html
评论列表(0条)