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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:24:47+00:00 2026-05-23T04:24:47+00:00

Let us start with the Javascript-code: <script type=text/javascript> var parentWindowLocation = ”; // closes

  • 0

Let us start with the Javascript-code:

<script type="text/javascript">
var parentWindowLocation = '';

// closes the popop of the search when the parent is closed
window.onload = function() {
    parentWindowLocation = window.opener.location;

    if (window.opener != null) {
        setInterval("checkParentExists()", 5000);
    }
}

function checkParentExists() {
    try {
        alert(window.opener.location);
        alert(parentWindowLocation);
        if (window.opener == null || window.opener.closed) {
            window.close();
        } else {
            if (parentWindowLocation != window.opener.location) { window.close(); }
        }
    } catch (e) { window.close(); }
}
</script>

The code above is specified in a popup. The popup should close itself when the parent is closed or if the URL of the parent has changed.
This works perfectly in Firefox and Chrome but not in Internet Explorer.

I’ve added the two alerts in checkParentExists() to see what happened in Internet Explorer.
I noticed that when the parent changes to a different URL (so window.opener.location changes) the variable parentWindowLocation is also set to the new URL of the parent! I only set the variable in window.onload so what happened?

  • 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-23T04:24:48+00:00Added an answer on May 23, 2026 at 4:24 am

    The “location” object is, well, an object. When you convert it to a string, you get something made from the properties of the object, but it’s not a string. Thus, your variable can still refer to the “location” object, but the value can change.

    If you set your variable to window.opener.location.href instead, you’ll get a string. You could also try this:

         parentWindowLocation = window.opener.location + '';
    

    which will also force it to be “captured” as a string.

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

Sidebar

Related Questions

Alright, to start with let's look at some code: <html> <body> <script type=text/javascript> function
Let me start out by saying that I'm not a JavaScript developer so this
Let me start by saying that I'm not a power-JavaScript/jQuery programmer, I do very
Let me start off by saying my JavaScript skills are lacking, to say the
Let me start by saying that I do not advocate this approach, but I
Let me start off with a bit of background. This morning one of our
Let me start with a specific example of what I'm trying to do. I
Let me start by saying I'm a huge fan of the elegance of this
Let's start with the following snippet: Foreach(Record item in RecordList){ .. item = UpdateRecord(item,
Let me start by explaining our set-up: I am working with some contractors. They

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.