为什么script要写在body之间才有用,我放在head之间就没有用了?。。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>操作成功</h1>
<span id="num">5</span><span>秒后返回主页 </span><span><a href="javascript:back();">返回</a></span>
<script>
function back(){
window.history.back();
}
var n=document.getElementById("num").innerHTML
function count(){
n--
document.getElementById("num").innerHTML=n
if(n==0){
window.location.assign("https://www.imooc.com/")
}
}
setInterval("count()",1000)
</script>
</body>
</html>