Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to close pop up after a certain amount of time. 1

Status
Not open for further replies.

jonnyGURU

IS-IT--Management
Aug 19, 2004
138
US
I thought I had it figured out. ;)

I have a pop-up window that I open with a window.open(). After so many seconds, I want that window to close. I figured I'd let the page refresh a new page and on unload, close the window completely.

No worky.

This is my lame attempt:

<HTML>
<META HTTP-EQUIV="refresh" content="5;URL=page.htm">
<BODY onUnload="window.close()">
Thanks! Now, good bye.
</BODY>
</HTML>

What should I be doing?

Dispensing quality rants and mishaps since 1999:
 
Two options:

1) Code for your popup page:
Code:
<!-- close this window after 10 seconds -->
<body onload="setTimeout('window.close()', 10000);">

2) Code for your main page:
Code:
var w = window.open('page.html','','');
setTimeout('w.close()'; 10000);

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Where do I put the

var w = window.open('page.html','','');
setTimeout('w.close()'; 10000);

on the first page and what is the 10000? Milliseconds?

Thanks cLFlaVa!!

Jon


Dispensing quality rants and mishaps since 1999:
 
i'll need to see some code. how are you opening the window?

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
It's a popup that's already open.

Essentially, I have a "request information" link. That opens the popup with a form in it. The SUBMIT button submits the info back to the server and opens the next page that's basically a "THANK YOU!" page that I want to close in 3 to 5 seconds.

Dispensing quality rants and mishaps since 1999:
 
then use option 1.


*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
oh yeah, sorry i forgot to answer that part.

yeah, JavaScript counts in milliseconds, so 10,000 is 10 seconds. If you wanted 5 seconds, it would be 5000.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top