• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic