【问题标题】:issue in IE browser while opening a new windowIE浏览器打开新窗口时出现问题
【发布时间】:2014-12-08 10:14:16
【问题描述】:

我有这么一小段代码

$("a").live("click",function(event) {
                    <% String lifeCare=LifeEventProperties.getInstance().getProperty("lifeCare");%>
                    var s="<%=lifeCare%>"; 
                    var href = $(this).attr('href');
                    if (href.indexOf(s) != -1) {
                        loadLifeCare(href) ;
                        event.preventDefault();
                    } 
                });

function loadLifeCare(href)
    {
        var wnd=window.open('/NASApp/benemain/LifeCareSite');
        setTimeout(function() {
            wnd.location.href = href;
        }, 6000);
    }

在我的 jsp 页面中,我使用 jquery 检查了 url 中的特定单词,该单词就像我从属性文件中获取的“something.com”,现在如果在 url 中找到这个 something.com用户点击了然后我正在调用一个javascript函数,然后打开一个带有内部站点url的新窗口,该窗口正在处理用户对具有this something.com的页面的会话,然后我用该用户的“href”重新加载页面点击。

问题是它在所有浏览器的其他 IE 中运行良好,我的客户喜欢 IE, IE 直接转到绕过 loadLifeCare 方法的链接并在控制台上给我这个错误

The value of the property 'loadLifeCare' is null or undefined, not a Function object 

任何人都可以提出为什么会发生这种情况吗?这段代码中是否有任何 IE 不理解的内容,我感觉可能是 window.open() 的问题,但我不确定而且我不知道如果是这样的话,甚至知道任何替代方案。

请帮助我,如果您需要任何澄清,请告诉我..

【问题讨论】:

    标签: javascript jquery html internet-explorer


    【解决方案1】:

    试试这个

    1. 修复了已弃用的live
    2. 使用了更好的方法来打开窗口(你的很可能拒绝访问;
    3. 将函数移到使用之前,并将单击事件处理程序包装在负载处理程序中

    function loadLifeCare(href) {
      var wnd=window.open('/NASApp/benemain/LifeCareSite',"lifeCareWin");
      if (wnd) setTimeout(function() {
        window.open(href,"lifeCareWin");
      }, 6000);
    }
    
    $(function() {
      $("a").on("click",function(event) {
        <% String lifeCare=LifeEventProperties.getInstance().getProperty("lifeCare");%>
        var s="<%=lifeCare%>"; 
        var href = $(this).attr("href"); // this.href might be useful too
        if (href.indexOf(s) != -1) {
          loadLifeCare(href) ;
          event.preventDefault();
        } 
      });
    });
    

    【讨论】:

    • 非常感谢..我在过去三个小时内试图解决这个问题,但没有成功,但你为我节省了很多精力,效果很好,再次感谢你的帮助我:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多