[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

How to alert the user when he/she "wonders" away?

knowledgenotebook

9/25/2015 10:25:00 PM

Hi,

The page has two panels, the left one with id of "leftPanel" and the right one with id of "rightPanel".

Each of them is inside a DIV.

The left DIV is a note entry form. To reduce the risk of unexpected problem with the computer and hence data loss, I've implemented automatic data/note saving every minute via ajax for windows OS -based computer, in this case, I use an Access database for storage. But for Mac, I'm using H2 db and it gives trouble for the automatic data saving via ajax. So, I wonder if there's a way to alert the user if he/she clicks anything on the Right Panel, which would result in data/note loss. The onbeforeunload is not applicable, a) it is applicable to body tag only; b) the given DIV does not unload, rather, the user's mouse moves to another DIV. Is there a solution to this problem?

Thanks.
1 Answer

Simon Blackwell

10/2/2015 12:47:00 AM

0

If I understand your problem correctly, you should be able to do this:

1) Any time an edit is made to the left panel set a dirty flag on a javascript object or even change the style of the div to give an indication it needs to be saved.
2) When your auto save succeeds clear the dirty flag or reset the style
3) When a user moves the mouse into the right panel check for the dirty flag or style, if it is present alert the user to save and when manual save is done clear the dirty flag or style.

Make sense?