Solved

Prevent user from closing form

Posted on 2007-11-28
4
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
EF5 How do I stop pre-compiled views? 8 54
Different Javascript on iPhone than Win 10 desktop? 7 54
Example code 13 42
Javascript function 3 20
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…

734 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