From 2dda55da1cb0382876ce5a841307b998cced53c6 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Sat, 31 Mar 2012 19:12:26 +1100 Subject: [PATCH] onload() function to handle multiple functions --- templates/main.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/templates/main.js b/templates/main.js index 42d38eb9..9e51aa7b 100644 --- a/templates/main.js +++ b/templates/main.js @@ -197,7 +197,26 @@ var RecaptchaOptions = { theme : 'clean' }; -window.onload = init; +function onload(fnc) { + if(typeof window.addEventListener != "undefined") { + window.addEventListener("load", fnc, false); + } else if(typeof window.attachEvent != "undefined") { + window.attachEvent( "onload", fnc ); + } else { + if (window.onload != null) { + var oldOnload = window.onload; + window.onload = function (e) { + oldOnload(e); + window[fnc](); + }; + } else { + window.onload = fnc; + } + } +} + +onload(init); + {% endraw %}{% if config.google_analytics %}{% raw %} var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}