代码示例:(标识:dhtm_event_onunload)
<html>
<head>

<script type="text/javascript">
function mymessage()
{
alert("该消息被 onunload 事件触发")
}
</script>
</head>

<body onunload="mymessage()">

<p>当您关闭该文档时,提示框会显示一条消息!</p>
</body>

</html>
运行结果: