From: Mabel C. <mc...@ya...> - 2003-03-14 18:30:23
|
Does it matter where we insert the external javascript file in the html code? If I put it within the body tag, it still doesn't load. For example: <body> <script language="Javascript" type="text/javascript" src="myFile.js"></script> <script language="Javascript" type="text/javascript"> someFunc(); </script> </body> Should I open a bug for this? --- Mike Bowler <mb...@Ga...> wrote: > > 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 > > > > ------------------------------------------------------- > This SF.net email is sponsored by:Crypto Challenge is now open! > Get cracking and register here for some mind boggling fun and > the chance of winning an Apple iPod: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > _______________________________________________ > HtmlUnit-develop mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-develop __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |