javascript - Why can the sessionStorage be saved when the onbeforeunload prompt box is closed and refreshed, but the alert cannot be played?
滿天的星座
滿天的星座 2017-05-19 10:30:57
0
1
734

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

滿天的星座
滿天的星座

reply all(1)
世界只因有你

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!