aspose file tools*
The moose likes Applets and the fly likes window.opener is changed during redirect from Applet in Java 1.7.0_04-b20 but not in 1.7.0_03-b5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "window.opener is changed during redirect from Applet in Java 1.7.0_04-b20 but not in 1.7.0_03-b5" Watch "window.opener is changed during redirect from Applet in Java 1.7.0_04-b20 but not in 1.7.0_03-b5" New topic
Author

window.opener is changed during redirect from Applet in Java 1.7.0_04-b20 but not in 1.7.0_03-b5

Sascha Kaestle
Greenhorn

Joined: Jul 30, 2012
Posts: 1
Hello everyone


I ran into an issue with the javascript property `window.opener` (which keeps a reference to the window that opened the popup) in conjunction with a redirect from within an applet. Whenever a redirect happens from within the applet, `window.opener` was changed to the current pop-up. Even stranger is the fact that this change was introduced with a recent java update quite recently: this did not happen with `java 1.7.0_03-b05` but started happening with `java 1.7.0_04-b20`. Now this might be some exotic usecase but still, I'm wondering if this change was intentional.

To get to the bottom of this I have written a small test to demonstrate the behavior in question. The HTML-Sites can be found here: http://files.newsnetz.ch/applet_test. It does only work in Firefox (which is OK for my usecase)



1. The `index.html` page contains the following javascript:



I set the windows name to "index.html" (for identification purpose) and provide a function that will open applet.html in a popup-window.
It also contains a link which calls this function:



2. after clicking the link, `applet.html` is opened in a popup. This contains the following javascript:


I set this popup's window.name to "applet.html" (for identification purpose) and alert the current `window.opener.name`. When the body fires the onload event, I change the openers background color to red.

Also, this page contains an applet, which has a button that will fire a redirect to `redirect.html`

3. after clicking the button in the applet, `redirect.html` is opened in the same popup-window. This page contains the following javascript:


I set this popup's window.name to "redirect.html" (for identification purpose) and alert the current `window.opener.name`. When the body fires the onload event, I change the openers background color to green.


With `java 1.7.0_03-b5` the following happens:

1. After clicking the link in `index.html`, `applet.html` is opened in a popup window. The alert shows `index.html` as being the openers name. Then the backgroundcolor of the opener is changed to red
2. After clicking the button in the applet `redirect.html` is opened in the same window. The alert shows `index.html`as being the openers name. Then the backgroundcolor of the opener is changed to green

so far so good... but with `java 1.7.0_04-b20` the following happens:

1. After clicking the link in `index.html`, `applet.html` is opened in a popup window. The alert shows `index.html` as being the openers name. Then the backgroundcolor of the opener is changed to red
2. After clicking the button in the applet `redirect.html` is opened in the same window. The alert shows 'redirect.html` as being the openersname. Then the backgroundcolor of the opener (which is the popup-window now!) is changed to green.

So it seems the redirect issued by the Applet via `this.getAppletContext().showDocument(new URL(this.getDocumentBase(), "redirect.html"), "_self");` changes the window.opener property to the window it changed the URL in...

I would appreciate any insights into why this behavior might have changed or if you could imagine a workaround to this problem.

Thanks a lot for your time
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: window.opener is changed during redirect from Applet in Java 1.7.0_04-b20 but not in 1.7.0_03-b5
 
Similar Threads
Getting values from popup window to parent window
Getting response values in a text box
post data from one window to another
Populating fields on a webpage based on the remote webpage data
Pop up problem in IE8