Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes How to stop browser window closing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to stop browser window closing" Watch "How to stop browser window closing" New topic
Author

How to stop browser window closing

Venkata Ramana
Greenhorn

Joined: Feb 14, 2002
Posts: 17
In javascript onbeforeunload event i called a method. as
<body onbeforeunload=fun>
This event is when i clicked on 'X' on top right corner.(i.e. before closing the browser window)
in 'fun' function i want to stop the browser window closing. how can i achieve this.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
<SCRIPT LANGUAGE=JavaScript FOR=window EVENT=onbeforeunload>
<!--
var strMsg = 'Leaving this page with will cause you to loose any information you have entered'
window.event.returnValue = strMsg;
// -->
</SCRIPT>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to stop browser window closing
 
Similar Threads
Cancelling Window onclose event.
Invalidation HttpSession upon closing the browser
onUnload() -- Very URGENT !!!
Can we still open a window using window.open if popups are blocked.
need to differentiate between the window closing an window refreshing