Purplefly
2016-09-08 17:18
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h3>操作成功</h3>
<span id="time">5</span>
<span>秒离开页面</span>
<a href="back()">返回</a>
<script>
var time = document.getElementById("time").innerHTML;
function clock(){
time--;
document.getElementById("time").innerHTML = time;
if(time == 0){
window.location.href("http://www.imooc.com");
}
}
setInterval(clock,1000);
function back(){
window.history.back();
}
</script>
</body>
</html>
href不是函数,是属性,应该用等于号赋值:window.loaction.href="http://www.imooc.com"
哦,谢啦
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题
回答 4
回答 1