• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Prevent user from closing form

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
joan2006
Asked:
joan2006
2 Solutions
 
Michel PlungjanIT ExpertCommented:
Not if they REALLY want to leave.
I think you want

<body onBeforeUnload="returnValue='Please fill it out before you leave'">
0
 
evilrixSenior Software Engineer (Avast)Commented:
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
 
Roopesh_7Commented:
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
 
itsbthCommented:
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now