为了账号安全,请及时绑定邮箱和手机立即绑定

正在回答

3 回答

你不定义i, 计算机不知道i是啥,是字符串,数字,或对象?所以报错i is not defined。

0 回复 有任何疑惑可以回复我~

<!DOCTYPE html>

<html>

 <head>

  <title>浏览器对象</title>  

  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>   

 </head>

 <body>

  <H4>操作成功</H4>

  <p>

     <b id="second">5</b>秒后回到主页&nbsp;<a href="javascript:goBack();">返回</a>  

  </p>

 

<script type="text/javascript">  

 

    var sec = document.getElementById("second");

var i = 5;

var timer = setInterval(function(){

i--;

sec.innerHTML = i;

if(i==1){

window.location.href =  "http://www.imooc.com/";

}

},1000);

 

  function goBack(){ 

window.history.go(-1);

  }  

  </script> 

 </body>

</html>


0 回复 有任何疑惑可以回复我~

哪里的变量i?

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
JavaScript进阶篇
  • 参与学习       468354    人
  • 解答问题       21893    个

本课程从如何插入JS代码开始,带您进入网页动态交互世界

进入课程

关于变量i

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信