在IE中打开一个弹出窗口 - “未找到会员” [英] opening a popup in IE - "Member not found"
问题描述
当用户打开一个在里面打开PDF的弹出窗口时,会发生这种情况。 (这部分有效)。
This happens in IE6 when the user opens a popup window that opens a PDF inside. (this part works).
然后,用户打开另一个弹出窗口,此时我收到此错误。
Then, the user opens another popup window, and at this point i get this error.
我的问题是:
有更好的解决方案吗?打开一个窗口并立即关闭它对我来说似乎是一个愚蠢的解决方案。
Is there a better solution? Opening up a window and closing it right away seems like a silly solution to me.
推荐答案
我想我有一个更好的解决方案不涉及首先关闭窗口。问题是,如果您尝试使用空URL(即'')再次打开窗口,IE将不会覆盖窗口(PDF或其他)。但将覆盖具有非空URL的PDF。这可能是一个文件,但是关于:空白的效果更好(这通常是一个空URL)。
I think I've got a better solution that doesn't involve closing the window first. The issue is that IE won't override a window (PDF or otherwise) if you attempt to open it again with an empty URL (i.e., ''). It will override a PDF with a non-empty URL, however. That could be a file, but about:blank works even better (which is what an empty URL does normally).
根据代码的编写方式,你仍然可以想要try / catch,但这应该消除了这个需求:
Depending on how your code is written, you may still want the try/catch, but this should eliminate the need:
windowHandle = window.open('about:blank',name,attributes);
windowHandle.document.location.href = url;
windowHandle.focus();
about:blank将强制PDF退出子窗口并允许您执行所需操作做。将URL和focus()的设置放在windowHandle.onload()处理程序中可能不是一个坏主意,因此处理PDF时没有任何时间问题。即:
about:blank will force the PDF out of the child window and allow you to do what you need to do. It might not be a bad idea to place the setting of the URL and focus() in a windowHandle.onload() handler, so there aren't any timing issues with disposing of the PDF. I.e.:
windowHandle.onload=function(){
windowHandle.document.location.href = url;
windowHandle.focus();
};
这篇关于在IE中打开一个弹出窗口 - “未找到会员”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!