Skip to content Skip to sidebar Skip to footer

Open A New Browser Window On Close Of Current Window If User Confirms To Close Current Window

I have a scenario where if the user tries to close the current browser window then he should be displayed a confirm box. If he confirms to close the window then this window should

Solution 1:

When a window closes, everything, absolutely everything associated with that window whether visible or not ... pending javascript code, stuff on screen, etc. vanishes and that includes the very scripts that are in the middle of execution - poof - gone nada, basically canceling, aborting, halting, stopping any running script.

The temporal sequencing requires that, except for closing a window, all other user initiated operations be completed first.

example:

javascript:
void(window.open("data:text/html,
<html><ahref=\"javascript:window.open('about:blank');self.close();void(0);\">open & close</a> this link does both<br/><ahref=\"javascript:self.close();window.open('about:blank');void(0);\">close & open</a> this does close but open fails
</html>
"))

The links can be preconditioned with if(confirm("quit??")){ ... }

tested with:

window.navigator.userAgent =
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101Firefox/11.0

Bookmark: Open a new browser window on close of current window if user confirms to close current window

Solution 2:

var answer = confirm("quit??");
if (answer){
    window.open("http://www.google.com/");
}
else{
// do something else
}

Post a Comment for "Open A New Browser Window On Close Of Current Window If User Confirms To Close Current Window"