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.
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.
Share Improve this question asked Jun 12, 2009 at 16:14 mkoryakmkoryak 58k64 gold badges203 silver badges262 bronze badges2 Answers
Reset to default 4I 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();
};
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.