I've been using it for almost 3 years, and it just gets better and better, with formatting xml responses, displaying images, reading AMF and so on. It's gold when developing with ajax or flash related server calls.

I like this solution, only that I agree with the comments saying the current approach is too specific to be used without thinking or testing. But maybe it's a good new starting point. As it fires once the DOM is ready, if not earlier, you'd have to check if you're complete or not. I can't come up with anything creative right now, possibly checking for some element at the bottom, in a loop, or something? Sounds terrible, I know.

Jakob Heuser said on February 20, 2008

Well, IE has a few properties that could be useful. For example, the activeElement property doesn't exist until the DOM is "ready" according to IE docs. We could just put f back onto the queue if the DOM doesn't seem ready in a progressive load under IE.


function DOMReady(f) {
  if (/(?!.*?compatible|.*?webkit)^mozilla|opera/i.test(navigator.userAgent)){ // Feeling dirty yet?
    document.addEventListener("DOMContentLoaded", f, false);
  }
  /*@cc_on @*/
  /*@if (@_win32)
  elseif(document.activeElement === null) {
    window.setTimeout(function() { DOMReady(f); }, 10); // back onto the event queue
  }
  /*@end @*/
  else{
    window.setTimeout(f,0);
  }
}

There are other ways too that get messy writing script elements with the IE-specific defer property, but the goal seems to be to try and keep the code short and sweet. That said, I am really not a fan of that anonymous function in the IE-specific setTimeout(), but my brain's too tired to figure out how to make it go away.

Brendon Kozlowski said on February 20, 2008

@Matthias: Thanks! If anyone else wants to elaborate a bit more on its use, I'd greatly appreciate it! I'll go take a look at it for now though. As for the DOMContentLoaded issue, most of the projects I've had, I haven't had an excuse to *not* use a JS library that solves the issue, thankfully.

Jenna said on February 24, 2008

Preved dyatlam!

Diego Perini said on September 04, 2008

I believe my IEContentLoaded trick has proven to be more precise and reliable on IE and will work both with compressed and uncompressed pages.

It has been proven by many that the setTimeout is unreliable in most situations, the exact moment is hard to detect, especially when navigating back and forward with the browsers buttons. Unfortunately the combinations we have to check are too many, better rely on something described by the browser vendor itself.

Diego Perini

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.
f2富二代官网入口