I want to close the window that opened a new window using window.opener.close().The problem is when this code is executed, some confirmation message pops up. Is there any way to stop this message from appearing in my window?
This is by design and you can’t change it. The idea being that closing the user’s browser window is impolite and they should have the opportunity to intervene. One additional thing to note is that the window.close() behavior also varies from browser to browser and between browser versions. This means that while one kind of browser will display a confirmation dialog to the user (like the one you mention), others may not.