我最后的那个 function history(){ window.history.back(); }有问题吗?怎么测试
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<p>操作成功</p>
<p><span id ="second">5</span><span>秒后回到主页</span><a href="#" onclick = "history()">返回</a></p>
<script type="text/javascript">
var fiveSecond = document.getElementById('second').innerHTML;
var num = 5;
function reduce(){
if (num > 0){
document.getElementById('second').innerHTML = num;
num = num-1
setTimeout("reduce()",1000);
}
else {
window.location.href = "http://www.imooc.com/";
}
}
reduce();
function history(){
window.history.back();
}
//获取显示秒数的元素,通过定时器来更改秒数。
//通过window的location和history对象来控制网页的跳转。
</script>
</body>
</html>