Forum Moderators: open

Message Too Old, No Replies

Would like to add a time delay to this Java pop-up

         

stcrim

11:30 pm on Jul 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would like to add a time delay to this Java pop-up

Any thoughts?
-s-

<!--____________begin pop-behind code____________-->

<script language="JavaScript">
<!-- Hide script from older browsers
{myWin = open('', 'winin','top=10,left=10,toolbar=0,menubar=0,scrollbars=1,status=0,resizable=1,width=650,height=460');
myWin.blur();
myWin.location = 'http://wwWebmasterWorldebsite.com/window/2nd/mysite/index.html';}
// end hiding contents -->
</script>

<!--____________end pop-behind code____________-->

Purple Martin

5:02 am on Jul 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My first thought is that you're pretty much guaranteed to annoy your visitors. Most people (including myself) detest pop-ups, especially ones that immediately hide themselves behind the parent window like yours does. Now you want to make things even worse by delaying it.

My advice (and I do mean this seriously) is to avoid the hidden pop-up completely. While I concede that there are a few very limited occasions where a pop-up can usefully add to the site's content, no hidden pop-up can do this, and is therefore only an annoyance with no useful purpose.

rewboss

7:02 am on Jul 30, 2002 (gmt 0)

10+ Year Member



All you need is the setTimeout() function. It is a method of the Window object, and it looks like this:

var timeoutID = setTimeout(code, delay);

code is a string containing the code to be executed, delay is the delay in milliseconds. You don't need to store the return value unless you need at some point to cancel the timeout.

var timeoutID = setTimeout("popUpWindow();", 5000);

...will wait five seconds before executing the code. To cancel the timeout, use the clearTimeout function:

clearTimeout(timeoutID);

Related to setTimeout is setInterval. It executes the code periodically:

var intervalID = setInterval("popUpWindow();", 5000);

...will execute the code every five seconds (which would really annoy). To cancel, use

clearInterval(intervalID);