java中的httpUnit错误

时间:2010-12-17 13:25:23

标签: java webclient

你好我正在使用httpUnit,我有以下错误

  

org.mozilla.javascript.EcmaError:TypeError:在对象[object Image]中找不到函数attachEvent。           在org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)           在org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)           在org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)           在org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)           在org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3743)           在org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2247)           在org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2214)           在org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3143)           在org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)           在org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)           在org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)           在org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)           在org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)           在org.mozilla.javascript.Context.evaluateString(Context.java:1104)           at com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:92)           at com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88)           在com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151)           at com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150)           at com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)           在org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1136)           在org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1038)           在org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)           在org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329)           在org.cyberneko.html.HTMLScanner $ ContentScanner.scanEndElement(HTMLScanner.java:2999)           在org.cyberneko.html.HTMLScanner $ ContentScanner.scan(HTMLScanner.java:1991)           在org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:895)           在org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)           在org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)           在org.apache.xerces.parsers.XMLParser.parse(未知来源)           在org.apache.xerces.parsers.DOMParser.parse(未知来源)           at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48)           在com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271)           at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301)           at com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285)           at com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024)           在com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)           在com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315)           at com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526)           在com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201)           at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)           在com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)           在com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199)           at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)           在com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)           在com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:125)           在com.meterware.httpunit.WebClient.getResponse(WebClient.java:96)           在websitereader.Main.main(Main.java:83)   线程“main”中的异常com.meterware.httpunit.ScriptException:Script'(function(){   var b,d,e,f; function g(a,c){if(a.removeEventListener){a.removeEventListener(“load”,c,false); a.removeEventListener(“error”,c,false)} else {a.detachEvent(“onload”,c); a.detachEvent(“onerror”,c)}} function h(a){f =(new Date).getTime(); ++ d; a = a | | window.event; var c = a.target || a.srcElement; g(c,h)} var i = document.getElementsByTagName(“img”); b = i.length; d = 0; for(var j = 0,K;Ĵ

我正在使用netbeans并添加jar rhino1_7R2(js,js14)和httpunit-1.7

我该如何解决呢?

1 个答案:

答案 0 :(得分:0)

堆栈跟踪的第一行显示:

org.mozilla.javascript.EcmaError: TypeError: Cannot find function attachEvent in object [object Image]

嗯,这可能意味着一个名为Image的对象没有一个名为attachEvent的函数,你在某个地方调用它。因为你没有提供相关的源代码,所以只是一个猜测。

顺便说一句,这一行

(function(){ var b,d,e,f;function g(a,c)

吓到我了。我希望你实际上不会真正留下那些名字的变量。