zoukankan      html  css  js  c++  java
  • location.href在IE中不会跳转到指定的页面

    刚刚发现一个IE6中的一个JS的bug,在IE6中使用location.href做页面跳转时不起作用。代码如下:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script language="javascript" type="text/javascript">
    function goUrl(url) {
    	location.href = url;
    }
    </script>
    </head>
    
    <body>
    <a href="javascript:;" onclick="goUrl('http://www.papabao.com')">跳转</a>
    </body>
    </html>
    

    在IE6中点击超链接时,当前页面没有反应,没有达到跳转的效果,在google搜索了一下,找到解决的方法,但是还是没有找到造成这样问题的原因,所以这里只能把解决方案记录一下:

    function goUrl(url) {
    location.href
    = url;
    // 在此处加上以下代码既可
    window.event.returnValue =false;
    }
  • 相关阅读:
    从服务器角度分析RPG游戏——NPC的AI
    羽翼特效设计
    坐骑特效设计(二)
    坐骑特效设计
    Unity AssetBundle打包资源工具
    有趣的进度条
    原生与组件
    bower
    yeoman
    grunt+bower+yo
  • 原文地址:https://www.cnblogs.com/yunfour/p/2076193.html
Copyright © 2011-2022 走看看