Click to See Complete Forum and Search --> : how do I delay pop-up window?


amandab_nyc
10-09-2004, 01:40 PM
I am using this code to launch a pop-up window when a page loads. I need to delay it by about 5 seconds.

Can anyone tell me how to do that?



<script>

function openpopup(){
var popurl="http://www.xx.com/xxmailweb/xxSetup?oid=153&save=1&email_address=#email_address#"
winpops=window.open(popurl,"","width=600,height=600,")
}

openpopup()
</script>

JPnyc
10-09-2004, 01:42 PM
Whatever the event handler is, just put setTimeout on the call.
example:

onclick="setTimeout('openpopup()', 5000)"

Jona
10-09-2004, 01:43 PM
<script type="text/javascript"><!--
var timer;

function openpopup(){
var popurl="http://www.xx.com/xxmailweb/xxSetup?oid=153&save=1&email_address=#email_address#";
winpops=window.open(popurl,"","width=600,height=600,");
clearTimeout(timer);
}

timer = window.setTimeout("openpopup()", 5000);
//--></script>


Edit: DUNSEL beat me to it! ;)

amandab_nyc
10-09-2004, 01:46 PM
Thank you. What does the 5000 mean? Is that 5 seconds?

Jona
10-09-2004, 01:47 PM
5,000 is milliseconds, which equals 5 seconds.