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 270011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:55:50+00:00 2026-05-11T23:55:50+00:00

I have asked this question before and the problem was half solved in the

  • 0

I have asked this question before and the problem was half solved in the sense I was helped to find out that Javascript has some tough security in place.

What I learnt: A parent Window opens a child window. The child window redirects to a different domain and gets redirected back. It attempts to fire off a function of the parent window upon closing itself.

window.opener.startLoad();

This leads to a permissions (security) problem and will not work.

(Half) New Problem: How can I get a window to open a child window and when it closes run a function in the parent window?

I need a very efficient way of doing this as this will be happening a lot!

Thank you for any help.

  • 1 1 Answer
  • 1 View
  • 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-05-11T23:55:51+00:00Added an answer on May 11, 2026 at 11:55 pm

    Try this:

    var win = window.open(url, name);
    win.onunload = afterChildClose; // afterChildClose() is the function.
    win.close(); // afterChildClose() should fire now.
    

    All this code would be located and executed in the parent window’s javascript (including afterChildClose()). You are creating the window and assigning the function to the unload event.

    Oh, one thing I just thought of. If the child window refreshes or navigates to another url, the onunload event will fire as well. If you only want the event to fire when the window is closed, you should include a check in afterChildClose() on win.closed.

    EDIT: Here is the code to two sample pages I put together to try this out.

    Parent window:

    <html>
    <body>
    <script type="text/javascript">
        var win = window.open("secondwindow.html", "woo");
        win.onunload =onun; 
    
        function onun() {
            if(win.location != "about:blank") // This is so that the function 
                                              // doesn't do anything when the 
                                              // window is first opened.
            {
                alert("closed");
            }
        }
    </script>
    </body>
    </html>
    

    child window (“secondwindow.html”):

    <html>
    <body>
    <script type="text/javascript">
        setTimeout('window.close();', 5000);
    </script>
    </body>
    </html>
    

    When I try opening the first document in firefox, it opens the window, the window waits 5 seconds and quits, and the first document shows the alert(), so it is working even when the sub window closes itself.

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

Sidebar

Related Questions

I have looked around here to see if somebody has asked this question before
I realise this question has been asked before however the previous answers have gotten
I see that this question has been asked before but the context around the
First, I know this question has been asked several times before and that in
I'm aware that this question may have been asked before, but I still haven't
This question has been asked before, but the answered ones I could find were
Ok, I see that people have asked this question before, but I'm seeing some
Okay, I know this question has been asked before: Previous Question I have also
I know this question has been asked before but I seem to have a
I'm sure this question has been asked before, but I can't seem to find

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.