opening a popup in IE - “Member not found”

拜拜、爱过 提交于 2019-12-10 19:38:02

问题


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.

There is a good description and a possible solution here

my question is this:

Is there a better solution? Opening up a window and closing it right away seems like a silly solution to me.


回答1:


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).

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 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();
};



回答2:


I solved the problem using a try catch block.

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();

Seems to work for me.



来源:https://stackoverflow.com/questions/987572/opening-a-popup-in-ie-member-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!