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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:09:32+00:00 2026-05-18T06:09:32+00:00

I am using javascript window.open method to open lets say http://www.google.com [its always going

  • 0

I am using javascript window.open method to open lets say http://www.google.com [its always going to be some external url]

I have stored the reference of the window object in a variable, the problem is that variable never gets null on the parent page and I am not able to alert the user that the pop up has been closed.

Here’s the code

 
        var winFB;
        var winTWt;
        var counterFB = 0;
        var counterTWT = 0;
        var timerFB;
        function openFB() {

            if (counterFB == 0) {
                winFB = window.open("http://www.google.com");
                counterFB = 1;
            }
            if (counterFB > 0) {
                alert(winFB);
                if (winFB == null) {
                    counterFB = 0;
                    clearTimeout(timerFB);
                    alert("Window Closed");
                }
            }
          timerFB= setTimeout("openFB()", 1000);
        }

    

I can not put any javascript code on the pop up/child window.

Hope someone can help me on this

  • 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-18T06:09:33+00:00Added an answer on May 18, 2026 at 6:09 am

    The window variable doesn’t get nulled out when it’s closed, however its .closed property is true, so just change your check to be for that property, like this:

    var winFB;
    var winTWt;
    var counterFB = 0;
    var counterTWT = 0;
    var timerFB;
    function openFB() {
        if (counterFB == 0) {
            winFB = window.open("http://www.google.com");
            counterFB = 1;
        }
        if (counterFB > 0) {
            if (winFB.closed) {
                counterFB = 0;
                clearTimeout(timerFB);
                alert("Window Closed");
            }
        }
        timerFB = setTimeout(openFB, 1000);
    }
    

    Also note the setTimeout() change, pass a function in whenever possible (almost always) rather than a string, you’ll have a lot less problems with scoping.

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

Sidebar

Related Questions

I need to redirect the user using JavaScript. Which is the preferred method? window.open(webpage.htm,
Is it possible to launch a new window in JavaScript using the window.Open function,
how can I open a modal window using javascript only. I can't use own
Currently, under IE8 and in IE7, using javascript window.open and target param is set
how to triggered open/save window by using javascript?
I am opening a popup window from javascript using window.open. I want to open
Is it possible to close parent window in Firefox 2.0 using JavaScript. I have
The JavaScript security settings on Internet Explorer for my customers disallow using window.external.AddFavorite, and
I'm using JavaScript to hide an image and show some text thats hidden under
I tried to 1) load an xml file using javascript as an object, say

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.