Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > See if form has changed when user leaves the page

Reply
Thread Tools

See if form has changed when user leaves the page

 
 
Alex
Guest
Posts: n/a
 
      12-28-2006
Hello everyone,

I'm sure a javascript exists to do this, but I'm having problems
finding it. If I have a form on a page, and any data on that form has
changed, I want the user to get a javascript pop-up telling them to
save the data before continuing. So if they're on the page, type in
the form at any place, and click say another tab or menu option without
saving, I want a message to appear to tell them to save before
continuing.

I've found these validation functions:
http://www.mattkruse.com/javascript/validations/

But I don't know if this'll do what I need as it appears to only
trigger when the user clicks Submit. I want the message to appear
whenever the user exits the page.

Thanks for any suggestions --

Alex

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-28-2006
Alex wrote:

> I'm sure a javascript exists to do this, but I'm having problems
> finding it. If I have a form on a page, and any data on that form has
> changed, I want the user to get a javascript pop-up telling them to
> save the data before continuing. So if they're on the page, type in
> the form at any place, and click say another tab or menu option without
> saving, I want a message to appear to tell them to save before
> continuing.


Some browsers (IE, recent Mozilla and Opera) support the onbeforeunload
event handler, it will trigger whenever some navigates away and ask the
user to confirm. See
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onbeforeunload.asp>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Summary of what happens to a packet as it enters and then leaves thePIX\ASA firewall - please correct if you see something wrong - thx t.eliason@eds.com Cisco 0 11-27-2007 08:00 AM
save all variables in a cookie when the user leaves the page windandwaves Javascript 4 02-26-2007 01:51 PM
Delete session cookie when user leaves my domain? Mike Dee Javascript 0 03-02-2006 05:43 AM
Capturing event when user leaves a cell? Tory ASP .Net Datagrid Control 0 04-21-2005 10:16 PM
How to delete temporary files when the user leaves the web page? Jorge_Beteta ASP .Net 4 01-12-2004 08:21 AM



Advertisments