慕前端0798377
2018-08-22 13:38
<!DOCTYPE HTML>
<html>
<head>
<script>
var sum=5;
function acc(){
document.getElementById("con").value=sum;
if(sum=0){
window.history.go(-1);
}
sum=sum-1;
var i=setInterval("acc()",1000);
}
function abb(){
window.history.back();
}
</script>
</head>
<body>
<h1>操作成功</h1><br />
<input type="text" id="con" value=5> <h2>秒后回到主页</h2><input type="button" value="返回" onclick="abb()" />
</body>
</html>
没有调用函数acc()
修改部分:
1.<body onload="acc()">
2. function acc(){
document.getElementById("con").value=sum;
sum--;
if(sum>0){
var i=setTimeout("acc()",1000);
}
else{
window.open('https://www.imooc.com','_self');
}
}
JavaScript进阶篇
468727 学习 · 22064 问题
相似问题