diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-12-12 15:47:47 -0500 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-12-12 15:47:47 -0500 |
commit | ff422a1d8903251da3768bd994753c2b04154ce9 (patch) | |
tree | 77d9c0672ef0f0b61837683ec9ecdd13af68251f | |
parent | 5b48f1412e8117372af081c513b8c8a41176d4e7 (diff) |
Improve javascript onload handling.
I noticed the onload hook running twice sometimes when using chromium.
Change from using arguments.callee.done to a onload_done variable fixed it.
I guess that the callee differed in chromium.
Probably the cause of the problem is that chrome supports both
window.onload and document.addEventListener.
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | underlays/javascript/ikiwiki.js | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index ccf45df94..eb8248804 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ ikiwiki (3.20091203) UNRELEASED; urgency=low * cvs: Add missing bit to Automator. * Add complete Spanish basewiki translation done by Fernando Gonzalez de Requena. + * Improve javascript onload handling. -- Joey Hess <joeyh@debian.org> Wed, 02 Dec 2009 17:22:21 -0500 diff --git a/underlays/javascript/ikiwiki.js b/underlays/javascript/ikiwiki.js index 1252f244f..aebc5cf7e 100644 --- a/underlays/javascript/ikiwiki.js +++ b/underlays/javascript/ikiwiki.js @@ -10,11 +10,13 @@ if (document.addEventListener) { // other browsers window.onload = run_hooks_onload; +var onload_done = 0; + function run_hooks_onload() { // avoid firing twice - if (arguments.callee.done) + if (onload_done) return; - arguments.callee.done = true; + onload_done = true; run_hooks("onload"); } |