logo

New Response

« Return to the main article

You are replying to:

  1. I can see value in the pre-unload event (wish for something cross-browser, though), but I'd prefer to use onchange handlers to the storage/comparison method being proposed.

    From the onload event, you can sweep through the form controls, placing any existing onchange handlers in a temponchange method for the control. Set the new handler to a function that will first try to run a temp handler (if it exists), and then runs any other handler code, such as setting a hidden form input called Change to true, or something like that.

    The only benefit I can see of the storage/comparison method is that it will not report a change if you alter a field value and then set it back to its original value (using onchange's will report this as a change - actually two of them).

    On the other hand, you don't have to ensure that your initial storage sweep happens before any intialization massaging of the data, etc.

    It seems a bit cleaner. Probably comes down to personal preference, though.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: