]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - underlays/javascript/ikiwiki.js
(no commit message)
[git.ikiwiki.info.git] / underlays / javascript / ikiwiki.js
index 14ddd0745a60abffb28aaec298488a8036d81025..1252f244f8429faab7d5e7dccdd175bdd37a33f7 100644 (file)
@@ -1,9 +1,21 @@
 // ikiwiki's javascript utility function library
 
 var hooks;
+
+// Run onload as soon as the DOM is ready, if possible.
+// gecko, opera 9
+if (document.addEventListener) {
+       document.addEventListener("DOMContentLoaded", run_hooks_onload, false);
+}
+// other browsers
 window.onload = run_hooks_onload;
 
 function run_hooks_onload() {
+       // avoid firing twice
+       if (arguments.callee.done)
+               return;
+       arguments.callee.done = true;
+
        run_hooks("onload");
 }