I've a site where I've putten this code to avoid errors:
$(function() {
var fnDocumentReady = function() {
if(document.readyState != "complete") {
setTimeout(function () { fnDocumentReady(); }, 300);
return;
}
//do stuff
};
fnDocumentReady();
});
But I've recently discovered that in FF 3.5 does not execute the code where the "do stuff" is. After analyzing and debbuging I realized that document.readySate
in FF is always undefined
. Is there any way to replace this for something else that works simila开发者_Python百科r??
Thanks!
To answer the why? part: document.readyState
was added in Firefox 3.6.
There's no need here for the extra check, jQuery already abstracts detecting when the DOM is ready, all you need is:
$(function() {
//do stuff
});
If you're wanting all the images loaded before your code runs, just use window.onload
instead, like this:
$(window).load(function() {
//do stuff
});
精彩评论