This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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.
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.
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 ]