开发者

Check if User has clicked "Ok" for "onbeforeunload event"

I am checking when the user closes the bro开发者_开发百科wser window, if he says ok, how i do I trigger some action, like opening another window or saving a form. If he chooses "cancel", it should stay in the same page (which is working now). pls share some idea on how to approach this issue

Sample Code


You cannot react to the user clicking on the "Leave this page" button. This is by design of the browser: if the user wants to leave, let him go.

If the user chooses to cancel, you can try a technique found in this answer to similar question to execute some custom code like saving changes or the like.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜