2

我想知道窗口是使用window.close()还是手动关闭的(比如单击十字或刷新,或 Alt + F4)。为此,我可以检查是否调用了 unload 事件,因为当我检查 Chrome 时,在执行window.close()时未调用 unload 事件

<!doctype html>
<html>
<head>
<script src="jquery-1.6.2.min.js"></script>
<script>
$(document).ready(function(){
$('#close').click(function(){
    window.close();
});
$(window).unload(function(){
    alert("hello");
});
});
</script>
</head>
<body>
<input type="button" id="close" value="close"/>

</body>
</html>

我想知道这是指定的行为,还是因浏览器而异

4

0 回答 0