javascript - Warum erscheint console.log() bei window.onbeforeunload nicht auf der Browserkonsole?
我想大声告诉你
我想大声告诉你 2017-05-19 10:32:10
0
2
475
window.onbeforeunload=function(){
  console.log("为啥不能运行");//这个为什么不出现控制台呢?
   return ;
}
我想大声告诉你
我想大声告诉你

Antworte allen(2)
黄舟
window.onbeforeunload=function(e){
  e.returnValue = 'something'
  console.log("为啥不能运行");
  return ;
}

必须给事件的returnValue属性绑定一个值,否则浏览器会直接关掉,就看不到console的输出了

世界只因有你
<body onbeforeunload="return ''">

http://www.runoob.com/jsref/event-onbeforeunload.html
 

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage