Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
onload event
EVENT: onunload
onunload="action"
The
onunload
event occurs just before the HTML document is unloaded or removed from viewing (also when the page is refreshed). When this event happens, the code calls a function that performs a desired action. For example, you may want an alert box to appear that provides useful information to the user.
It can be used with either the
body
or
frameset
tags.
In contrast, the
onload
event occurs just after the HTML document is loaded for viewing.
In this example, the
onunload
event causes an alert box with a message to appear when you exit the page.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML onunload Tag Example</title>
</head>
<body>
<body
onunload="JavaScript:alert('Thank you for\nvisiting DevGuru!')"
>
Please exit or refresh this page to see output.
<br />
The alert box should appear.
</body>
</html>
Output:
Click to view and test output in a separate window
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information