轻新无限sou
2018-09-23 17:04
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>浏览器对象</title>
</head>
<body>
<h2>操作成功</h2> <br>
<p>
<strong id="times">5</strong>秒后返回到主页<a href="https://www.imooc.com"> 返回</a>
</p>
<script type="text/javascript">
var num=5,cancel;
function back1(){
var time=document.getElementById("times");
time.firstChild.nodeValue=num;
num=num-1;
cancel=setTimeout("back1()",1000);
if(num==0){
clearTimeout(cancel);
window.open("https://www.imooc.com","_self");
}
}
setTimeout("back1()",300);
</script>
</body>
</html>
从逻辑和结构上没看出什么问题,挺好的。
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题