onunload Attributeonunload AttributeThe onunload attribute may be used on
the body element
to specify script to be executed on leaving the page. Please do not
irritate your visitors by using this attribute to, for example, open
pop-up windows when they leave a page! [My personal opinion is that
the onunload handler should not do anything which visibly or audibly
affects the user in any way!]
See also the onload attribute.
If you use this attribute (or any attributes of Type Script) the MIME type of the scripting language used should always be provided in a Content-Script-Type HTTP header.
It is good practice not to use these attributes, however,
and instead to include external scripts (via
script elements)
which add any handlers unobtrusively. This makes code more self-contained and
also the XHTML is easier to maintain if it doesn't contain any events attributes.