有时在页面的刷新会触发 window.onbeforeunload()事件,只要加一个判断就可以了。
function window.onbeforeunload() { if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey){ window.event.returnValue="确定要退出本页吗?"; }