js 页面离开前触发事件 当前窗口载入新的dom文档前发生 1 window.onbeforeunload = function(event) { return confirm("确定离开此页面吗?");