-1

Possible Duplicate:
Difference between onbeforeunload and onunload

What is the difference between body.onunload and body.onbeforeunload events? As I understand I can use onunload and onbeforeunload on any other HTML element. Is it useful? If so, when?

Community
  • 1
  • 1

2 Answers2

0

onBeforeUnload isn't really supported - it's a Microsoft IE event.

Matt H
  • 6,422
  • 2
  • 28
  • 32
0

As you can see here: onbeforeunload and onunload the main difference is that onbeforeunload is cancelable.

So for example, when you type in an answer in stackoverflow, don't post it but press something else, you'll get a dialog saying This page is asking you to confirm that you want to leave - data you have entered may not be saved. and a button to cancel.

Thats when onbeforeunload is useful.

Ron Sijm
  • 8,490
  • 2
  • 31
  • 48