...

View Full Version : Problem Adding javascript function calls during onload page event



henryv
11-10-2010, 11:20 PM
I have the following javascript function:

[ function addNewWindowEvent(evType, fn)
{
if (window.addEventListener)
{
this.addEventListener("load", fn, false);
return true;
}
else if (window.attachEvent)
{
var onload = "onload"
this.attachEvent(onload, fn);
return true;
}
else
{
return false;
}
} ]

which is giving me a an exception every time a page on our site loads. The actual exception in firefox is this:

uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://cms-dev.stchas.edu/global/js/hdvscripts.js :: addNewWindowEvent :: line 5" data: no]

and I'm not sure exactly what it's complaining about. I'm relatively new to javascript so diagnosing and fixing this problem has me quite puzzled, and so far I have been unable to find anything helpful when I try and google for information on this. I would appreciate any help or suggestions. Thanks.

henryv

DrDOS
11-10-2010, 11:40 PM
Right before the close body tag, the one with the / , make a script tag and but all the function calls you want to make in it in proper order. If the functions are called one only time you can put the function calls for one function in another. You can also make a new function with all the calls in it, in proper order, and call it with window.onload = function().



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum