Solved

Prevent user from closing form

Posted on 2007-11-28
4
311 Views
Last Modified: 2008-02-01
HI All,

Is there a way to stop a user from closing windows explorer when they click on the X button on the top left of internet explorer?
0
Comment
Question by:joan2006
4 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 250 total points
ID: 20365693
Not if they REALLY want to leave.
I think you want

<body onBeforeUnload="returnValue='Please fill it out before you leave'">
0
 
LVL 40

Expert Comment

by:evilrix
ID: 20365990
There is no way to prevent this. You need to design your application to take this into account. So, for example, do not commit form details to a database until you have captured and validated all necessary input; otherwise, you might ruin your database integrity.
0
 
LVL 6

Expert Comment

by:Roopesh_7
ID: 20366010
When you use window.open, you can set titlebar to no or 0, but it is usually ignored, see link.
The alternative is to create a draggable div instead of a popup.
this link will help you

http://www.thescripts.com/forum/thread617779.html
0
 
LVL 1

Assisted Solution

by:itsbth
itsbth earned 250 total points
ID: 20366055
This code should work. Remember that a visitor might be irritated by the fact that he has to press yes to exit. You can disable it by setting window.onbeforeunload to null.
window.onbeforeunload = function(){
	return "Are you sure you want to close the window?"
}

Open in new window

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 38
How to calculate height of a text using jquery 3 40
Using/Import statement in code doesn't see reference of dll just added. 3 25
Read text on Table 7 25
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question