alive落叶
2016-02-27 14:05
<!DOCTYPE html> <html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <!--先编写好网页布局--> <p>操作成功</p> <p><span id="num">5</span>秒后返回主页<input type="button" value="返回" onclick="goback()"></p> <script type="text/javascript"> var num=5; function numChange(){ num--; if(num<0) window.location.href('www.imooc.com'); else document.getElementById('num').innerHTML=num; setTimeout('numChange',1000); } function goback(){ window.history.go(-1); } setTimeout('numChange,1000'); </script> </body> </html>
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<!--先编写好网页布局-->
<p>操作成功</p>
<p><span id="num">5</span>秒后返回主页<input type="button" value="返回" onclick="goback()"></p>
<script type="text/javascript">
var num=5;
function numChange(){
num--;
if(num<0)
//window.location.href('www.imooc.com');
window.location.href="http://www.imooc.com";
else
document.getElementById('num').innerHTML=num;
setTimeout('numChange()',1000);
}
function goback(){
window.history.go(-1);
}
setTimeout('numChange()',1000);
</script>
</body>
</html>
问题解决
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<!--先编写好网页布局-->
<p>操作成功</p>
<p><span id="num">5</span>秒后返回主页<input type="button" value="返回" onclick="goback()"></p>
<script type="text/javascript">
var num=5;
function numChange(){
num--;
if(num<0)
window.location.href="http://www.imooc.com";
else
document.getElementById('num').innerHTML=num;
setTimeout('numChange()',1000);
}
function goback(){
window.history.go(-1);
}
setTimeout('numChange()',1000);
</script>
</body>
</html>
没有for循环
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题