【问题标题】:opening a popup in IE - "Member not found"在 IE 中打开一个弹出窗口 - “找不到成员”
【发布时间】:2009-06-12 16:14:29
【问题描述】:

当用户打开一个在其中打开 PDF 的弹出窗口时,在 IE6 中会发生这种情况。 (这部分有效)。

然后,用户打开另一个弹出窗口,此时我收到此错误。

有一个good description and a possible solution here

我的问题是这样的:

有没有更好的解决方案?打开一个窗口并立即关闭它对我来说似乎是一个愚蠢的解决方案。

【问题讨论】:

    标签: javascript internet-explorer pdf popup


    【解决方案1】:

    我想我有一个更好的解决方案,它不需要先关闭窗口。问题是,如果您尝试使用空 URL(即“”)再次打开一个窗口(PDF 或其他),IE 不会覆盖它。但是,它覆盖具有非空 URL 的 PDF。这可能是一个文件,但 about:blank 效果更好(这是空 URL 通常的作用)。

    根据您的代码编写方式,您可能仍需要 try/catch,但这应该消除了这种需要:

    windowHandle = window.open('about:blank',name,attributes);
    windowHandle.document.location.href = url;
    windowHandle.focus();
    

    about:blank 将强制 PDF 退出子窗口并允许您执行您需要执行的操作。将 URL 和 focus() 的设置放在 windowHandle.onload() 处理程序中可能不是一个坏主意,因此处理 PDF 没有任何时间问题。即:

    windowHandle.onload=function(){
        windowHandle.document.location.href = url;
        windowHandle.focus();
    };
    

    【讨论】:

      【解决方案2】:

      我使用 try catch 块解决了这个问题。

      windowHandle = window.open('',name,attributes);
      try {
          windowHandle.document.location.href = url;
      } catch (exc) {
          windowHandle.close();
          windowHandle = window.open('',name,attributes);
          windowHandle.document.location.href = url + suffix;
      }
      windowHandle.focus();
      

      似乎对我有用。

      【讨论】:

      • 有趣,下次遇到这个问题试试你的解决方案
      猜你喜欢
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 2011-02-16
      • 1970-01-01
      • 1970-01-01
      • 2015-04-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多