Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:36:04+00:00 2026-06-11T07:36:04+00:00

I ran into an issue with the javascript property window.opener (which keeps a reference

  • 0

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. It does only work in Firefox (which is OK for my usecase)

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

    window.name = "index.html";
    
    function open_new_window() {
        window.open('applet.html', 'applet.html', 'width=1050,height=680,scrollbars=yes,status=yes').focus();
        return false;
    }
    

    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:

    <a href="#" onclick="open_new_window(); return false;">open applet.html in new                
    window</a>
    
  2. after clicking the link, applet.html is opened in a popup. This contains the following javascript:

    window.name = "HelloWorldApplet.html";
    
    alert("opener is now: "+window.opener.name);
    
    function on_load() {
        alert("changing bgcolor of opener to red");
        window.opener.document.body.style.background='red';
    }
    

    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

    import java.applet.Applet;
    import java.awt.Button;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    public class HelloWorldApplet extends Applet implements ActionListener {
    
        Button redirectButton;
    
        @Override
        public void init() {
            super.init();
    
            setLayout(new FlowLayout());
            redirectButton = new Button("Redirect now!");
            add(redirectButton);
    
            redirectButton.addActionListener(this);
        }
    
        @Override
        public void actionPerformed(ActionEvent ae) {
            try {
                this.getAppletContext().showDocument(new URL(this.getDocumentBase(), "redirect.html"), "_self");
            } catch (MalformedURLException ex) {
                Logger.getLogger(HelloWorldApplet.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
  3. after clicking the button in the applet, redirect.html is opened in the same popup-window. This page contains the following javascript:

    window.name = "redirect.html";
    
    alert("opener is now: "+window.opener.name);
    function on_load() {
        alert("changing bgcolor of opener to green");
        window.opener.document.body.style.background='green';
    }
    

    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.htmlas 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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:36:05+00:00Added an answer on June 11, 2026 at 7:36 am

    Your post helped me understand that I’m not the only one going crazy here. I believe this is a bug in the new java version.

    I simply added the following javascript to my popup page:

    var parentWin = window.opener;

    then, when I need to call the parent, I use parentWin. This solved my problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new to C++, but i have ran into an issue which
I ran into a strange issue with tinyMCE that i was not able to
Has anyone ran into this issue? We have a mobile site that can't use
I recently ran into an issue at work in which, at least according to
I ran into an issue with some third party software that we use to
I ran into an issue that can only be explained with my fundamental lack
I ran into an issue with something that I am probably just overlooking. I
I ran into an issue using a struct today that caught me off guard,
I ran into what seems to be a silly issue with some Javascript: go
I ran into an issue that I've been researching for hours to no avail.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.