From: Marc G. <mgu...@ya...> - 2005-08-15 07:01:12
|
You can open a bug issue for that but note that your code is useless: when you use window.open, the opener property is automatically set to the current window. Marc. Ramachandran, Neelamegam wrote: > Hi, > > I am getting an error when I try to set the window.opener property. The > html works fine in all the browsers. > > ERROR [com.gargoylesoftware.htmlunit.ScriptEngine] runtimeError: > message=[Property "opener" is not writable for > com.gargoylesoftware.htmlunit.javascript.host.Window@290fbc. Cant set it > to: com.gargoylesoftware.htmlunit.javascript.host.Window@290fbc] > sourceName=[null] line=[0] lineSource=[null] lineOffset=[0] > > > > This is my Java code: > > final WebClient webClient = new WebClient(); > > webClient.setThrowExceptionOnScriptError(false); > > final URL url = new URL(urlString); > > final HtmlPage page = (HtmlPage)webClient.getPage(url); > > List anchors = page.getAnchors(); > > Iterator itr = anchors.iterator(); > > while(itr.hasNext()) { > > HtmlAnchor anchor = (HtmlAnchor)itr.next(); > > String text = anchor.getHrefAttribute(); > > if (text.startsWith("javascript:")) { > > HtmlPage page1 = (HtmlPage)anchor.click(); > > } > > } > > This is my HTML code: > > <html> > > <script> > > function openwin() { > > var win = window.open("http://www.google.com"); > > win.opener = this; > > } > > </script> > > <a href="javascript:openwin()">Open</a> > > </html> > > > > Thanks, > > Neel. > |