From: Mike B. <mb...@Ga...> - 2003-01-10 18:04:22
|
Hi Mark, > An exception is thrown when an onLoad handler a form. Are there plans > to change this in a future release? The problem isn't with the onload handler. It's complaining because the variable "myForm" in the following line isn't defined. myForm.myText.value = s1.toUpperCase() I tried your sample with Mozilla and it also complained about "myForm" not being defined. Internet Explorer seemed to like it which makes me think that this is IE specific behaviour. I did a quick search to see who supports this behaviour but I can't actually find it documented anywhere. I would recommend that you use portable ways of accessing the form but if this way is important to you then please open a feature request. -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com DEMATTEIS, MARK S [AG-Contractor/1000] wrote: > An exception is thrown when an onLoad handler a form. Are there plans to > change this in a future release? > >Exception >--------------- >Exception in thread "main" com.gargoylesoftware.htmlunit.ScriptException: >"myForm" is not defined. > at >com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScript >Engine.java:162) > at >com.gargoylesoftware.htmlunit.html.HtmlPage.executeScriptTagsIfNeeded(HtmlPa >ge.java:748) > at >com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:102) > at >com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:318) > at >com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:238) > at >com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:180) > at Test.testOnload(Test.java:37) > at Test.execute(Test.java:29) > at Test.main(Test.java:18) > >Code: >------------------------- > void testOnload() throws java.net.MalformedURLException, >java.io.IOException > { > String myUrl = "http://localhost:/page4.html"; > WebClient webClient = new WebClient(); > HtmlPage page = (HtmlPage) webClient.getPage(new URL(myUrl)); > } > >HTML Page >---------------------- > ><html> ><head> ><title>Fourth Page</title> ></head> > ><body onload = "changeValue()" > ><form action="" method="POST" id="myForm" > ><input type="text" name="myText" > > ><script type="text/javascript" language="JavaScript"> >s1 = new String(myForm.myText.value) > >function changeValue() { > s1 = "Hello!" > myForm.myText.value = s1.toUpperCase() >} > ></script> ></form> ></body> ></html> > >Mark Dematteis > > >------------------------------------------------------- >This SF.NET email is sponsored by: >SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! >http://www.vasoftware.com >_______________________________________________ >HtmlUnit-develop mailing list >Htm...@li... >https://lists.sourceforge.net/lists/listinfo/htmlunit-develop > > > |