From: Ahmed A. <asa...@ya...> - 2016-06-22 08:50:52
|
Hi Jack, Can you post a complete case please? Cross-Origin is tested in https://sourceforge.net/p/htmlunit/code/HEAD/tree/trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequestCORSTest.java Ahmed From: jack <lil...@16...> To: htm...@li... Sent: Tuesday, June 21, 2016 7:36 AM Subject: [Htmlunit-user] How to solve the cross domain problem caused by the error Program error message: EcmaError: lineNumber=[41] column=[0] lineSource=[<no source>] name=[TypeError] sourceName=[http://live3.win007.com/common2.js] message=[TypeError: Cannot read property "childNodes" from null (http://live3.win007.com/common2.js#41)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "childNodes" from null (http://live3.win007.com/common2.js#41) common2.js message: function getOddsData() { oddsHttp.open("get", "vbsxml/goalBf3.xml?r=007" + Date.parse(new Date()), false); oddsHttp.setRequestHeader("User-Agent", ""); oddsHttp.send(null); var root = oddsHttp.responseXML.documentElement.childNodes[0]; ..... oddsHttp as XMLHttpRequest I suspect that a cross domain problem leads to " Cannot read property "childNodes"" I think about using this method to solve the problem,but there is no specific solution. public WebResponse getResponse(WebRequest request) throws IOException { if(request.getUrl().toExternalForm().contains("common2.js")){ .... } } |