开发者

Window.OnBeforeUnload

开发者 https://www.devze.com 2023-01-21 07:21 出处:网络
I am trying to create a customisation to our existing software, which launches on this event. I need to be able to catch the window.onbeforeunload again once the user has made their choice.

I am trying to create a customisation to our existing software, which launches on this event. I need to be able to catch the window.onbeforeunload again once the user has made their choice.

I have tried wrapping the functions but can't seem to be able to overwrite the one which is loaded first. Does anyone have any ideas about how I can approach this, or force the newly assigned function to overwrite the old开发者_运维百科 one.


You can not cancel the unload depending on which button the user presses, and you can not invoke this event manually. It's not even a standard event. Think of the vulnerabilities that could be used for malicious purposes if the event had the capabilities you want it to have.

This is about all you can do...

window.onbeforeunload = function() {
  alert("one"); // First time, choose to stay on page
  window.onbeforeunload = function() {
    alert("two");  // Second time
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号