<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
var timeId ;
function loadTime(){//每秒钟时间计数器就执行一次countLoad()函数 直到执行到计数器消除
timeId = setInterval("countLoad();", 1000);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body οnlοad="loadTime();">
页面 <font id="num" color="blue">5</font> 秒后转到客车之家首页!
<script type="text/javascript">
var sec = 5;
function countLoad(){
if(sec > 0){
document.getElementById("num").innerHTML = sec--;
}
else {
clearInterval(timeId);
location.href="http://www.bushome.net/";
}
}
</script>
</body>
</html>
javaScript利用计时器setInterval()定时后转到另一个页面的小程序
最新推荐文章于 2021-06-23 07:05:07 发布