<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"></meta>
<title>自動排程 Schedule</title>
<script type="text/javascript">
//alert("hello");
// 一秒鐘之後 排程動作的基本
// setTimeout only執行一次countdown 倒數
// setInterval 每秒鐘執行一次countdown 倒數
var timer;
function init(){
timer = document.getElementById("timer");
//window.setInterval(countdown,1000);
window.setInterval(countdown,1000);
}
function countdown(){
timer.innerHTML = timer.innerHTML-1;
if(timer.innerHTML > 0){
//window.setTimeout(countdown,1000);
}else{
document.location="http://www.sina.com";
}
}
</script>
</head>
<body onload = "init();">
<span id = "timer">3</span>
</body>
</html>