对于safari,onunload在页面关闭时不起作用

时间:2015-01-05 06:14:18

标签: html onunload

<body onunload="notReady()">
<script >
    function notReady(){
      alert("closing")
    }
</script>
</body>

只有在刷新页面或者粘贴页面上的某些链接并且页面实际正在卸载时才有效,但是当它正在关闭时它不起作用。

为什么?以及如何使它工作?

1 个答案:

答案 0 :(得分:1)

应该有用,

window.onbeforeunload = function() {
    return "closing!";
};