stay123
2015-01-22 11:35
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<h1>操作成功</h1>
<p><span id="timer">5</span>秒后回到主页 <a href="www.imooc.com">返回</a></p>
<script type="text/javascript">
var num=5;
function fun(){
num--;
if(document.getElementById("timer").innerHTML==0){
location.href("www.imooc.com");
}
else{
document.getElementById("timer").innerHTML=num;
setTimeout(fun,1000);
}
setTimeout(fun,1000);
}
</script>
</body>
</html>
哪不懂?
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题