From: Mabel C. <mc...@ya...> - 2003-03-13 17:56:36
|
I read in an archived message that someone else had a problem with htmlunit not recognizing external javascript files and that message was dated 9/2002. I am using version 1.2 (3/10/2003), but I am having the same problem. 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? thanks, mabel __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |
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 |
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 |
From: Mike B. <mb...@Ga...> - 2003-03-14 19:36:18
|
Mabel Chow wrote: > Does it matter where we insert the external javascript file in the html > code? If I'm right about the problem then no, it won't make a difference where the external file is specified. > Should I open a bug for this? Yes please. I'll see if I can get to it this weekend. -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |