只需一句简短的语句就可以兼容IE,火狐和Chrome window.onbeforeunload = function() { return 'Sure to leave?'; }; 摘自:点击打开链接