注册延迟
<!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>
<title>注册</title>
<script type="text/javascript">
var count = 10; //全局变量
var intervalId;
function countDown() {
var reg = document.getElementById('registerBtn');
if (reg) {//得先加载控件,因为如果网速慢的话,可能在控件加载之前,定时器就开始运行了
count--;
if (count <= 0) {
reg.disabled = "";
reg.value = "同意";
clearInterval(intervalId);//停止计时器
}
else {
reg.value = "请仔细阅读以上条款,同意后才能注册,还剩(" + count + ")秒";
}
}
}
</script>
</head>
<body onload="intervalId=setInterval('countDown()',1000);">
<textarea rows="4"></textarea>
<table><tr><input type="button" id="registerBtn" value="请仔细阅读以上条款,同意后才能注册,还剩(10)秒" disabled="disabled" />
</tr></table>
</body>
</html>