Reputation: 1
I am trying to close the parent window of a popup, but I get the confirmation box in the parent window. I know this is an IE security "feature" but it will be very annoying to my users. I am aware of the "fix" where you do this
window.open('link', 'toolbar=no,menubar=...'); window.open('', '_self', ''); window.close();
The issue is that I want to close the parent window from the child window with a link. I know you can also set the parent of the window on the child, but that does not seem to work either. Is there any fix out there to do this. Thanks for the help.
Upvotes: 0
Views: 3421
Reputation: 3554
You can't get around that security issue in IE (at least not directly).
One thing you could do is replace the DOM from the original window with the popup's DOM and then close the child. Effectively transferring the HTML markup from child to parent.
//within child
var childContent = document.getElementsTagName('body')[0].innerHTML;
// set parent HTML to the child's content
window.opener.document.getElementsTagName('body')[0].innerHTML = childContent;
// close child window
window.close();
Would that hack do it for you?
Upvotes: 2