慕粉3491582
2018-09-17 18:28
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h2>操作成功</h2>
<span id="m">5</span>
<p>秒后返回主页</p>
<a href="javascript:b();">返回</a>
<script type="text/javascript">
//获取显示秒数的元素,通过定时器来更改秒数。
var sum=document.getElementById("m").innerHTML;
function back(){
sum=sum-1;
document.getElementById("m").innerHTML=sum;
if(sum==0){
window.location.assign("www.baidu.com");
}
}
setInterval('back()',1000);}
//通过window的location和history对象来控制网页的跳转。
function b(){
window.history.go(-1);
}
</script>
</body>
</html>
试试 window.location.href="https://www.imooc.com";这个跳转
解决 倒计时了, setInterval多了 一个 括号 ,可是 倒计时 虽然出来了 ,时间到了 却不跳转呢 是为啥
JavaScript进阶篇
468740 学习 · 22112 问题
相似问题