//可阻止页面刷新、跳转、关闭 window.onbeforeunload = function(event){ event=event||window.event; event.returnValue="确定要离开当前页面?"; }; //而window.onunload不会阻止页面刷新、跳转或关闭,只是在走前留下一句话