문제

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 similar??

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
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top