<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>5秒后跳转到另一个页面</title>
<script type="text/javascript">
var t = 5;
function countDown(){
var time = document.getElementById("time");
t--;
time.value=t;
if (t<=0) {
location.href="http://www.baidu.com";
clearInterval(inter);
};
}
var inter = setInterval("countDown()",1000);
//window.οnlοad=countDown;
</script>
</head>
<body οnlοad="countDown()">
</html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>5秒后跳转到另一个页面</title>
<script type="text/javascript">
var t = 5;
function countDown(){
var time = document.getElementById("time");
t--;
time.value=t;
if (t<=0) {
location.href="http://www.baidu.com";
clearInterval(inter);
};
}
var inter = setInterval("countDown()",1000);
//window.οnlοad=countDown;
</script>
</head>
<body οnlοad="countDown()">
<input type="text" readonly="true" value="5" id="time"/>
<!--也可以在这里写javascript代码,这样就不必在body标签中写οnlοad="countDown()"。-->
</html>