<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<script type="text/javascript">
function chnagemade()
{
}
function setToRed( )
{
document.getElementById("colourButton").style.color = "#FF0000";
setTimeout ( "setToBlack()", 2000 );
}
function setToBlack( )
{
document.getElementById("colourButton").style.color = "#000000";
}
</script>
<input type="button" name="clickMe" id="colourButton" value="Click me and wait!" onclick="setToRed()"/>
</body>
</html>
// ------------------------------------------------------------------
<script language="Javascript">
var timeout;
function timeout_trigger() {
document.getElementById('timeout_text').innerHTML = 'The timeout has been triggered';
}
function timeout_clear() {
clearTimeout(timeout);
document.getElementById('timeout_text').innerHTML = 'The timeout has been cleared';
}
function timeout_init() {
timeout = setTimeout('timeout_trigger()', 3000);
document.getElementById('timeout_text').innerHTML = 'The timeout has been started';
}
</script>
<div>
<input type="button" value="test timeout" onclick="timeout_init()" />
<input type="button" value="clear timeout" onclick="timeout_clear()" />
</div>
<div id="timeout_text"></div>
// ------------------------------------------------------------------
<script type="text/javascript">
var alertTimerId = 0;
function alertTimerClickHandler ( )
{
if ( document.getElementById("alertTimerButton").value == "Click me and wait!" )
{
// Start the timer
document.getElementById("alertTimerButton").value = "Click me to stop the timer!";
alertTimerId = setTimeout ( "showAlert()", 3000 );
}
else
{
document.getElementById("alertTimerButton").value = "Click me and wait!";
clearTimeout ( alertTimerId );
}
}
function showAlert ( )
{
alert ( "Too late! You didn't stop the timer." );
document.getElementById("alertTimerButton").value = "Click me and wait!";
}
</script>
<input type="button" name="clickMe" id="alertTimerButton" value="Click me and wait!" onclick="alertTimerClickHandler()"/>