Fri 14th Oct 2005
Posted late at night, filed under
Blogsome ,
JavaScript.
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…
Fri 14th Oct 2005
Posted mid-morning, filed under
JavaScript.
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?