...

View Full Version : using multiple timers in one Window



shelly323
06-09-2004, 07:34 AM
Hi. I am needing help with pop-up windows. I have a main form with a function in it that calls a pop-up tip from an array every 15 seconds. It continually
changes the tip until the user clicks the "close" button. At this point, I want the
pop-up box to close, wait 5 minutes, and reopen the pop-up. I know I need to
put this code in the onclick event of the close button, but how do I code it?

Here's my main window:

<html>
<head>
<title>We Be Toys</title>
<script language="JavaScript" type="text/javascript">
<!--
function showTips(){
tips = window.open("tips.html", "TipsWin", "width=150, height=180")
tipsTimer = setTimeout("tips.close()","14000")
}
//-->
</script>
</head>
<body bgcolor="87CEF6">
<h1 align ="center">--We Be Toys--</h1>

<script language="JavaScript" type="text/javascript">
<!--
window.setInterval("showTips()", "15000")
</script>
<h2 align="center">Welcome to our Web Site! Thanks for stopping by.</h2>
<p align="center"><img src ="yoyo.JPG" alt = "Yo-Yo Mamas" border="2"></p>
</body>
</html>

here's my pop-up window:

<html>
<head>
<title>Handy Tips</title>
<script language="JavaScript" src ="tips.js"></script>
</head>
<body bgcolor="C2E3F6">
<div align=center>
<script language="JavaScript" type="text/javascript">
document.write("<b>Tip:<br><br>"+randomTips()+"<br>")
</script>
<form>
<input type ="button" value = "Close" onClick= self.close()>
</form>
</div>
</body>
</html>


Thanks very much.

Kor
06-09-2004, 09:44 AM
Try this:

<script language="JavaScript" type="text/javascript">
<!--

function reopen(){
setTimeout('showTips',5000)
}

function showTips(){
tips = window.open("tips.html", "TipsWin", "width=150, height=180")
tipsTimer = setTimeout("tips.close()","14000")
}
//-->
</script>

and in popup

<input type ="button" value = "Close" onClick= "window.opener.reopen();self.close()">

Kor
06-09-2004, 09:45 AM
sorry
function reopen(){
setTimeout('showTips()',5000)
}

glenngv
06-09-2004, 11:22 AM
You should check if opener is still open.
<input type ="button" value = "Close" onClick= "if (opener&&!opener.closed)window.opener.reopen();self.close()">

shelly323
06-09-2004, 04:59 PM
Thanks SO much, both of you. It works!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum