By filiptc on
I got this error after linking the drupal.js manually from the page.tpl.php in order to execute several onload functions through the following script which requires lines 175-189 from drupal.js:
<script type="text/javascript">
if (isJsEnabled()) {
addLoadEvent(my_onload_function1);
addLoadEvent(my_onload_function2);
}
</script>After manually adding the link to the drupal.js from my page.tpl.php I got the IE js error "object expected on line 186, char 7, code 0; and Firefox error "func is not a function" for the same line.
The code in drupal.js:
175: /**
176: * Adds a function to the window onload event
177: */
178: function addLoadEvent(func) {
179: var oldOnload = window.onload;
180: if (typeof window.onload != 'function') {
181: window.onload = func;
182: }
183: else {
184: window.onload = function() {
185: oldOnload();
186: func();
187: }
188: }
189: }
What is wrong, and is there any other way to execute onload functions without messing up the
<body <?php print theme("onload_attribute"); ?> > (which conflicts with any body onload="function()" tag)?
Thanks,
Phil