Cross Browser Script Up

My script is now up and running, and cross-browser. I’ll leave the Catchpa slightly disabled for the time being so I can test it a bit more on different machines. You’ll also notice a nice little floating toolbar – this is only supposed to appear on the site when a user is logged in, but it seems to be there all of the time at the moment. The script is about 56k, which I think is too big, however I’ve had some issues with the compression utility I was using, so I’ll roll my own solution. It is all in one file again, (easier to manage updating it), and I think the browser caches it, so it should only be slow on the first load. Things I need to do:

  • Set it up so the true.gif and false.gif images are preloaded, so there is no delay on the first time a user clicks on a checkbox.
  • Have a tag in the template for enabling/disabling checkbox replacement.
  • Fix up admin toolbar.

I’m sure there’s probably other stuff I need to do…

DOMContentLoaded and Safari

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:

 1     //Main Startup Code
 2     
 3     function checkDOM(){
 4         if (document.getElementById("footer")
 5          || document.getElementById("credit")) 
 6             Startup();
 7         else
 8             setTimeout("checkDOM();",100);
 9     }
10     
11     if (document.addEventListener)
12         document.addEventListener("DOMContentLoaded", Startup, null);
13     else 
14         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:

1     if (document.addEventListener && (navigator.vendor != "Apple Computer, Inc."))

I’d rather not have to do things like this. Why not?