<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<p>操作成功</p>
<span id="seconds">5</span>
<span>秒后回到主页</span>
<a href="javascript:before()">返回</a>
<script type="text/javascript">
function before() {
window.history.back();
}
//获取显示秒数的元素,通过定时器来更改秒数。
var num = document.getElementById("seconds").innerHTML;
function backToMain() {
if(num=0) {
window.location.assign("www.imooc.com");
}
num = num-1;
document.getElementById("seconds").innerHTML = num;
}
//通过window的location和history对象来控制网页的跳转。
setInterval("backToMain()", 1000);
</script>
</body>
</html>
if(num=0)少了个等号if(num==0)