DOMContentLoaded and Safari
-
Comments:
- here.
Often, you will want some scripts to run when the page has loaded, even if the images on it haven’t. I wrote up some stuff about this under Best pre-onload. My full onDOMReady script looks like:
//Main Startup Code
function checkDOM(){
if (document.getElementById("footer")
|| document.getElementById("credit"))
Startup();
else
setTimeout("checkDOM();",100);
}
if (document.addEventListener)
document.addEventListener("DOMContentLoaded", Startup, null);
else
setTimeout("checkDOM();",100);
However, Safari will not load pages that use this, since it has document.addEventListener
, but does not create DOMContentLoaded
events. So, I had to create a nasty little browser check rule:
if (document.addEventListener && (navigator.vendor != "Apple Computer, Inc."))
I’d rather not have to do things like this. Why not?