<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!-- 6秒後跳轉到http://www.baidu.com -->
<form name="form1">
<input type="text" name="clock" size="2" value="6" />秒後自動跳轉網頁
</form>
<!-- 設定定時器,每一秒時間減1 -->
<script type="text/javascript">
var time1 = parseInt(document.getElementsByTagName("input")[0].value);//轉為Number型
function myFunction(){
if(time1<=0){
//alert(1);
// location.href = "http://www.baidu.com";
window.open("http://www.baidu.com");
clearInterval(a);
}
document.getElementsByTagName("input")[0].value = time1;
time1--;
}
var a = setInterval(myFunction,1000);
</script>
</body>
</html>