onunload有什么用呀,页面都已经关掉了
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> 卸载事件 </title>
<script type="text/javascript">
var win;
window.onunload = onunload_message;
function onunload_message(){
alert("您确定离开该网页吗?");
}
function openwin(){
win = window.open("http://www.imooc.com","_blank","width=300,height=300");
}
function closewin(){
win.onunload = onunload_message;
win.close();
}
</script>
</head>
<body>
欢迎学习JavaScript。
<input type="button" value="打开新窗口" onclick="openwin();" />
<input type="button" value="测试弹窗关闭" onclick="closewin();" />
</body>
</html>如我的代码,这样页面都已经关掉了,这个提示还有什么用呢