| Author |
Control browser close event
|
Gavi Raaghav
Ranch Hand
Joined: Apr 28, 2005
Posts: 82
|
|
When the user tries to close the browser i need to present him with a confirm dialog box of OK/Cancel. Clicking on OK will close the browser and clicking on Cancel will keep the user on the same screen. How to achieve this using Javascript. onUnload() calls the function but whatever be the user action the browser closes. Any pointers will be highly appreciated.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
only way to do it is IE only and that is the onbeforeunload event handler. There is not other way to capture the close, you have to realize that the back button, refresh button, links, and closing the browser fire the same event, hence why it basically is impossible to determine what happened. Eric
|
 |
 |
|
|
subject: Control browser close event
|
|
|