卸载事件(onunload)

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> 卸载事件 </title>
<script type="text/javascript">  
     window.onunload = onunload_message;  
     function onunload_message(){  
        alert("您确定离开该网页吗?");  
    }  
</script>  
</head>
<body>
  欢迎学习JavaScript。
</body>
</html>

原文地址:https://www.cnblogs.com/www-hsy-com/p/7757882.html