How to remove prompt on unload event using javascript

前端 未结 2 1508
一生所求
一生所求 2021-01-15 14:44

How can I remove prompt on unload event using javascript? thanks in advance...

hm, I don\'t want to show the prompt when firing the custom function for the unlaod ev

2条回答
  •  悲哀的现实
    2021-01-15 15:11

    Make sure your event handler doesn't have a return statement in it. Returning from the function triggers the conformation message.

    Update based on the code comments in the edited question: If the user does something to leave the page, then you can tell the browser to ask them if they are sure. You cannot silently prevent them. If the user wishes to leave the page, then they can do so (dodgy sites full of adverts and/or malware would love it to be otherwise, thankfully it isn't)

提交回复
热议问题