|
From: DEMATTEIS, M. S [AG-Contractor/1000]
<mar...@mo...> - 2003-01-10 17:29:54
|
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
|