How to stop browser pange closing without showing confirm dialog box
Venkata Ramana
Greenhorn
Joined: Feb 14, 2002
Posts: 17
posted
0
Hi I need to stop my browser page closing when user clicks on 'X' symbol located at top right carner. i used the following html and javascipt code.
The above code is working fine. When the user clicks on 'X' symbol, it will promt in confirm dialog box.If user clicks on 'ok' the browser window will close. if user clicks on 'cancel' the browser don't close. I don't want to display the confirm dialog box, and i want my browser window to be opened. (i.e. actually i want to cancel the event which fires when 'X' button is clicked.) ramana
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
posted
0
i dont think you can thank god! although i have been to sites that popped up windows faster than i could close them ive never been unable to close one. you can make them really big so the X is off the screen, but it can still be closed by right clicking on it in the task bar.
SCJP
Heath Lilley
Ranch Hand
Joined: Jan 09, 2001
Posts: 72
posted
0
You can't STOP them from closing the window but in I.E. 5.5 there is a confirm window of some sort the works a little like an alert. It pops up a mini dialog window with OK and Cancel buttons on the bottom. Here is where you can ask them if they really want to close the window. If u are writing some kind of webapp you could simulate a call to logout code on the server with the on close method if the user clicks OK. You can also save the user's session data, at that point, if you need to.
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
posted
0
he knows about the confirm dialog box. thats what hes trying to avoid. why do you want to be so mean to your visitors/users anyway? by the way, you do realize that onbeforeunload only works in IE dont you? [ April 18, 2002: Message edited by: Randall Twede ]
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
You can do an onunload pop up of the same page they were on......But most people will close them before they will open.