window.onbeforeunload=function(){
console.log("为啥不能运行");//这个为什么不出现控制台呢?
return ;
}
黄舟2017-05-19 10:34:10
window.onbeforeunload=function(e){
e.returnValue = 'something'
console.log("为啥不能运行");
return ;
}
You must bind a value to the returnValue attribute of the event, otherwise the browser will be closed directly and you will not be able to see the console output
世界只因有你2017-05-19 10:34:10
<body onbeforeunload="return ''">
http://www.runoob.com/jsref/event-onbeforeunload.html