timerhandle = setTimeout(“jump”,5000)
end function
function jump()
document.location = “colorriot.jpg”
end function
function stopTimer()
clearTimeout(timerhandle)
end function
</script>
</head>
<body onload=”startTimer()” onunload=”stopTimer()”>
<img src=”andy.jpg”>
</body>
</html>
For the document.locationvalue, you can provide a second .htm file if you
wish. Here’s how to load a Web page located on the root directory of c: drive
on the same computer as the one on which the first .htm file resides:
document.location = “file:///C:/cheese.htm”
Grasping countdown timers ............................................................
A countdown timer (which counts down from a set value, like a kitchen
timer) is created by using the settimeoutcommand, like this:
timerhandle = setTimeout(“movep”,3000)
You can use almost any name instead of timerhandlehere (except a word
already used by VBScript, such as Endor Function). However, timerhandle
seems like a good name for it. The timerhandleis just a name that’s given to
the timer when it’s created by the above line of script (when the page with
this script loads into a browser). You can later destroy this timer by using its
name, as in this line:
clearTimeout(timerhandle)
The clearTimeoutcommand removes the timer from the computer’s memory
(destroys it, really). The clearTimeoutcommand isn’t strictly necessary.
Generally, you can count on the computer to destroy timers that are no longer
in use. However, explicitly killing off a timer when your program is finished
using it is considered good programming practice.