If the browswer is closing I need to warn the user.. giving them a
chance to save the data changes.
If, however, we're going to a link on the same site, I'll save the
changes automatically on the postback... thus making a notification to
the user not only unnecessary, but annoying.
This is not acceptable behavior for an internet application - there are
too many ways a user can leave the site besides closing the browser,
plus some users don't have javascript enabled at all. What should happen
if the user grabs a URL from the favs? What if they type it? What if
they click a link in mail and it re-uses the window (mine does that)?
What if the browser crashes? What if the next version of Mozilla lets
users disable this feature (onunload)?
For an intranet application, it is acceptable, but still unnecessary if
the application is programmed properly.
One way to handle this is by storing data in active sessions. If the
user doesn't save the data, it is autosaved (or you notify the user via
mail or some such if possible) when the session expires (sessions expire
a certain amount of time after the browser is closed). A good example of
this is the shopping cart at amazon (I think that's where it was). If
you put stuff in your cart, but don't check out, they send you a mail
asking you if you still wanted the items and giving you a chance to
still buy them. If you don't respond in a certain amount of time, the
items are removed from the cart.
--