<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h2>操作成功</h2>
<p><span id="mySecond">5</span>秒后返回主页 <a href="javascript:goBack();">返回</a></p>
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
var num=4;
function count(){
document.getElementById("mySecond").innerHTML = num;
num--;
setTimeout("count()",1000);
if(num==1){
window.location.assign("http://www.baidu.com");
}
}
setTimeout("count()",1000);
//通过window.history对象来控制网页的跳转。
function goBack(){
window.history.back();
}
</script>
</body>
</html>
js 计时器页面跳转
最新推荐文章于 2021-06-29 19:59:11 发布