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

这段代码在IE运行正常,但在FF下直接无视掉了IF的条件判断,好奇怪,求问。

<!DOCTYPE html>
<html>
 <head>
  <title>浏览器对象</title>  
  <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>   
 </head>
 <body onload="setTimeout('timer()',1000)">
  <!--先编写好网页布局-->
  <h1>操作成功</h1>
  <span id="seconds">5</span>
  <span>秒后返回</span><a href="javascript:bak()">返回</a>
  
 
  <script type="text/javascript">  
 //获取显示秒数的元素,通过定时器来更改秒数。
 var num=document.getElementById("seconds").innerHTML;
 var clock=setInterval(function timer()
  {
    document.getElementById("seconds").innerHTML=num;
  	num--;
  	if(num==0){
  		location.href("http://www.imooc.com");
  		clearInterval(i);
  	}
  },1000)
 //通过window的location和history对象来控制网页的跳转。
 function bak()
 {
 	history.back();
 }

   
 </script> 
</body>
</html>


正在回答

1 回答

不是if语句没有生效,是location.href("http://www.imooc.com");错了,改为location.href="http://www.imooc.com";

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

举报

0/150
提交
取消

这段代码在IE运行正常,但在FF下直接无视掉了IF的条件判断,好奇怪,求问。

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