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

  • Home
  • SEARCH
  • 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
  • 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-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

Ask A Question

Stats

  • Questions 241k
  • Answers 241k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer On POSIX-compliant platforms, SIGPIPE is the signal sent to a… May 13, 2026 at 7:31 am
  • Editorial Team
    Editorial Team added an answer You don't need JavaScript for the hover. Make an element… May 13, 2026 at 7:30 am
  • Editorial Team
    Editorial Team added an answer not sure about a standard list, but there is SpecWeb2005… May 13, 2026 at 7:30 am

Related Questions

Ok, I asked this question before, but deleted it as the way I went
I have asked a similar question before, but I didn't have a firm grasp
This relates to another question I asked earlier today. I built SVN 1.6.2 from
I was just think that now it is common to have enough RAM on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.