您现在的位置: 万盛学电脑网 >> 程序编程 >> 脚本专题 >> javascript >> 正文

window.location.href IE下跳转失效的解决方法

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 这篇文章主要介绍了window.location.href IE下跳转失效的解决方法,需要的朋友可以参考下

代码如下: <a href="javascript:void(0)" >GoNext</a>  $("a").click(function(){  window.location.href = "xxx.html";  })    代码如上,在IE下,特别是在IE6中,点击超链接之后,浏览器并没有发生跳转行为。    原因可能是因为在href中的javascript:void(0)阻止的事件行为,解决方法如下:    1.在onclick事件中加return false来阻止冒泡:   代码如下: $("a").click(function(){  window.location.href = "xxx.html";  reutrn false;  })    2.延迟100毫秒  代码如下: $("a").click(function(){  setTimeout(function(){  window.location.href = "xxx.html";  },100);  })