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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:18:53+00:00 2026-05-26T17:18:53+00:00

I am sure this is a generic question been asked many times, can’t find

  • 0

I am sure this is a generic question been asked many times, can’t find solution though.

I have javascript using setTimeout() function to close a popup window I created after a set time.

Issue:
if I call setTimeout() function within the same script as the one that created the popup window, the popup window does not display the contents of the window, instead the whole thing functions like a single script and the window closes. Its like you need to interrupt the script somehow to get it to parse each section of script before doing the setTimeout.

Does anyone know why or have a workaround?

<script>
var w;
function closeWindow(){ setTimeout(w.close();, 10000);}

function createWindow(){
//create the popup window.

w=window.open("","",'width=200,height=100');

// put something into the popup window
try{w.document.write('<html><head></head><body><p>the w window</p></body>  
<html>')}catch(err){
//handle error here
}

closeWindow();

//closes the createWindow() function
}
</script>
  • 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-26T17:18:54+00:00Added an answer on May 26, 2026 at 5:18 pm

    I played around with your script. The following is tested and functioning:

    var w;
    function closeWindow(){ setTimeout("w.close();", 10000);}
    
    function createWindow(){
    //create the popup window.
    
    w=window.open("","",'width=200,height=100');
    
    // put something into the popup window
    try{w.document.write('<html><head></head><body><p>the w window</p></body> <html>')}catch(err){
    //handle error here
    }
    closeWindow();
    //closes the createWindow() function
    }
    

    If I remember correctly, the quotes are required around the code parameter of your setTimeout function because otherwise you would be passing the return value of the code as an argument for setTimeout rather than the code it needs to run.

    Hope this helps.

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

Sidebar

Related Questions

I'm pretty sure this is a duplicate question, but I can't find the original(s).
I'm sure this has already been asked and answered so I apologize in advance
This is more a generic question than a specific one. I'm trying to have
this is a more generic question: I am trying to find a way to
This is a generic question, and although I'm pretty sure some of it's parts
Sorry if this is generic in nature, but I have a question that maybe
Can someone explain this behavior in Generics? I have a generic function in C#
I know this is a bit generic, but I'm sure you'll understand my explanation.
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I
Im sure this will be a simple one but have a project that started

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.