http://www.runoob.com/jsref/e...
After hooking up.
Refresh it again
The function body will not be triggered at all.
I tested it. Why is this?
Just leave it unchecked
window.addEventListener("beforeunload", function(event) {
alert("弹出");
sessionStorage.name="你的名字"; //请教一下为什么这个sessionStorage都能存下来?而alert没弹出来?这是什么机制啊?
});
http://jsbin.com/zisazacani/e... JS Bin online example
世界只因有你2017-05-19 10:32:57
Thanks for the invitation
Official documentation explains
Starting from May 25, 2011, the HTML5 specification states that in this event handler, calls to window.alert(), window.confirm(), and
window.prompt() will be ignored. See the HTML5 specification for details.
In addition, this is for security reasons and does not allow disabling system pop-ups.