js中的页面跳转

js中的页面跳转相当于jsp中的重定向:

window.location.href = “xxx.jsp”;

但有时window.location.href 有时会失效..这又是万恶的IE的BUG.以下是解决的方法:

微软上公布3个解决方案的.

原文地址:http://support.microsoft.com/kb/190244/en-us

 

第一种:

在window.location.href 后面加上 window.event.returnValue = false;

如:

<a href="#" onclick="window.location.href='http://www.microsoft.com';
   window.event.returnValue=false;">

第二种:

把window.location.href写成 JavaScript:window.location.href

如:

<a href="JavaScript:window.location.href='http://www.microsoft.com';">

第三种:

不写 href 直接写onlick .然后通过css样式来控制鼠标移上去显示手型效果.

如:

<a onclick="window.location.href='http://www.microsoft.com';"
   onmouseover="window.status='http://www.microsoft.com';"
   onmouseout="window.status='';"
   style="cursor:pointer; text-decoration:underline; color:blue;
   font-family:times new roman">

参考:http://blog.sina.com.cn/s/blog_49ca87fc0100xvvf.html
posted @ 2015-08-05 12:12  tooker  阅读(369)  评论(0编辑  收藏  举报