<p><span id="seconds">5</span>秒后回到主页
<script type="text/javascript">
var num=document.getElementById("seconds").innerHtml;
function clock(){
num--;
document.getElementById("seconds").innerHtml=num;
if (num == 1){
window.location.assign("http://www.imooc.com");
}
}
var i= getInterval(clock,1000);
innerHtml应该改为innerHTML,getInterval应该是setInterval:
<script type="text/javascript">
var num=document.getElementById("seconds").innerHTML;
function clock(){
num--;
document.getElementById("seconds").innerHTML=num;
if (num == 1){
window.location.assign("http://www.imooc.com");
}
}
var i= setInterval(clock,1000);
</script>
</p>?