View Full Version : Preventing user from leaving the page

05-05-2006, 05:09 PM

I have a requirement to display a message box and prevent user from leaving the page until he has saved fields on current page. Now the problem is that I am using a menu control (ComponentArt menu control). All is working fine for me unless the user drops down a menu (say File) and selects and submenu item (say open) and clicks upon it, the validation doesn't fire and the user gets able to leave to the clicked URL. Any ideas how can I accomplish this?

Thanks & Regards,
Omer Javed

Davide Zanotti
05-05-2006, 06:10 PM
I think you can try something like this:

return false;

05-06-2006, 12:28 AM
Once onunload is triggered your visitor has already left the page.

Some browsers (but not all because it is non-standard) have an onbeforeunload event handler.

05-06-2006, 01:01 AM
Read this thread. (http://forums.devshed.com/t228939/s.html)