Unload Events In Java Script

This event occurs when the focus from the page gets lost because of some link etc.
 
Example:
 

<html>

<head>

<title>events </title>

</head>

<body bgcolor=green text=”white” onload=”wel()” onunload=”thx()”>

<marquee direction=up behavior=alternate scrollamount=5 size=0>

<h1 align=center> Welcome </h1>

</marquee>

<h1> Click on link to unload this page </h1>

<a href=’exeventonload.php’> hit me to unload this page </a>

<script>

function wel()

{

document.bgColor=’yellow’

document.fgColor=’blue’

}

function thx()

{

alert(“Thanx to visit me “)

}

</script>

</body>

</html>