prevent onbeforeunload to close page in any case

后端 未结 2 1537
自闭症患者
自闭症患者 2021-01-12 09:44

I want to prevent browser to close page in any case or in other case, Prevent browser to do anything when onbeforeunload is called. Here is my code which i hav

相关标签:
2条回答
  • 2021-01-12 10:14

    There is no way to stop browser to close. The browser doesn't allow you to do that.

    0 讨论(0)
  • 2021-01-12 10:32

    You can't outright prevent a user from leaving the page (This would lead to much abuse on spam/advertisement sites who try to get you to stay on a page), but you can show things such as a window which causes a confirm prompt to the user. Have a look at Prevent a webpage from navigating away using JavaScript which can lead you to the right direction of what you're trying to accomplish.

    0 讨论(0)
提交回复
热议问题