Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Using setTimeout/setInterval - code


<head>

<script language="javascript">

function showReminder(){

var doNotRemind //Declare the local variable doNotRemind /*
Use the prompt method of the window object to inform the user
and to ask if they Do Not want to be reminded again.
If the user activates the confirm button true is returned otherwise false is
*/
doNotRemind = confirm("This web site is moving to
http://JShoutcut.com in two days!\do not remind me again!")

if(doNotRemind){// if the user does not want to be reminded again
/*
Use the clearTimeout method of the window object to free the memory
and never call this function again (unless the user reloads the document)
so the user will never be informed again.
*/
clearTimeout(timerId)
}else{//The user wants to be reminded again
/*
Use the setTimeout method since I do not want to call this
function straight away but rather wait for a two second delay then call it.
Give the setTimeout method this function's name as the first
parameter (in quotes) and the delay as the second parameter (in no quotes)
This method returns a pointer to this setTimeout that is cleared as soon as
doNotRemind is true by using clearTimeout method.
*/
timerId = setTimeout("showReminder()",2000)
}
}
}
</script> </head>

<!--

Make the onload event call the showReminder function
--> <body
onLoad="showReminder()"
> </body><!-- Close the body element -->


Close