From: Mike B. <mb...@Ga...> - 2003-03-14 02:12:56
|
Mabel Chow wrote: > When I reference an external javascript file within the <head> tag and > call a function using onLoad attribute, <body onLoad="someFunc();">, it > CAN recognize someFunc(). However, if I use > > <body> > <script language="Javascript" type="text/javascript"> > someFunc(); > </script> > </body> > > I get ScriptException: "someFunc()" is not defined. > Any ideas why and solutions? Looks like you've found a bug in the way I'm loading the javascript. This code went through some significant changes for 1.2 in order to support document.write(). The external script file isn't getting loaded until the entire html file has been parsed but the script tag within the body is executed *during* the parsing of the html. When the inner script is executed, the external file hasn't been loaded. By the time the onload handler is invoked, all the external scripts have been loaded so that works properly. I'll have to write up some tests to prove that it is broken the way I suspect. -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |