Thursday, April 12, 2007

Milena Velba Y Nadine

TIPS - Warning before leaving a Web page

Often a user, carried by the spirit of navigation, click on a link when it is drafting a form that has not yet registered. It must then redo everything and ends up bitter.

Under Lotus Notes, when closing a form, the fat client has the thoughtfulness to warn the user that he should save his data before exiting. It is actually quite simple to do the same thing on the Web.


Detection of an amendment on Form
Before the warning, you'd better check that it is really worthwhile. A simple way is to rely on a field that will changed when a field was modified based on onChange event. This field of control need not be visible to the user so we can declare it as type "hidden" is:
  \u0026lt;input type = "hidden" name = "isChanged" id = "isChanged" value = "0">  


To change the field value, use a Javascript function which can be declared in a bookstore or simply in the "JS Header" of the mask.
This function may be of the form:
  formChange function () {
document.forms [0]. IsChanged.value = "1";}


can then call the function in the onChange event for each field that you want to control by adding:
  formChange ()  



Detecting the user exits the form
must declare the new event onbeforeunload. For this, the JS in the header mask, add
  window.onbeforeunload = confirmExit;  
where confirmExit is a Javascript function to check whether to display the warning box but also to personalize the message a little .
  confirmExit function () {
if (document.forms [0]. IsChanged.value == '1 ')
return "You're making changes without saving them."
} The first condition to check whether it is useful to present the confirmation window by going to check the value of hidden field.