I was trying to open a custom window using "window.open" from index.html (opener) and close the opener without browser prompt or warning message.
I used window.parent.close(); to clone the opener. window.parent.close works perfectly in all browsers except IE, which is used by maximum users. In IE it ways prompts the user to with message "Do you want to close this window or tab (if the opener is in new tab)", this is due to security reasons.
In IE a window can be closed via JavaScript if it was opened by a JavaScript. In order to close the parent window, we must open a new page or the same page in parent window with "_self" as the target using JavaScript, which will overwrite your current parent window and then close the window.
Here is the code;
I used window.parent.close(); to clone the opener. window.parent.close works perfectly in all browsers except IE, which is used by maximum users. In IE it ways prompts the user to with message "Do you want to close this window or tab (if the opener is in new tab)", this is due to security reasons.
In IE a window can be closed via JavaScript if it was opened by a JavaScript. In order to close the parent window, we must open a new page or the same page in parent window with "_self" as the target using JavaScript, which will overwrite your current parent window and then close the window.
Here is the code;
In index.html, on load calling openCustomWindow function;
window.onload = function () { openCustomWindow(); } openCustomWindow () { window.open(url, winName, params, false); window.parent.open('', '_self', ''); window.parent.close(); }