更新时间:2022-11-18 14:11:50
此功能正常工作,与Visual Studio无关。在你的问题中,你是混合了一些东西,我不知道为什么。
另外,你真的不需要onebeforeunload
,也许你可以使用onunload
代替。请参阅:
http:/ /msdn.microsoft.com/en-us/library/ie/ms536907%28v=vs.85%29.aspx [ ^ ]。
如果您需要阻止用户从您的页面导航,那么您只需要(顺便说一句,这通常不是很好,但您可以要求用户确认并仍然允许如果确认,则离开页面)。另见此讨论: http://***.com/questions/3775566/javascript-question-onbeforeunload -or-onunload [ ^ ]。
-SA
This functionality just works and is not related to Visual Studio whatsoever. In your question, you are mixing somethings up, I don't know why.
Also, it is not apparent that you really needonebeforeunload
, maybe you can useonunload
instead. Please see:
http://msdn.microsoft.com/en-us/library/ie/ms536907%28v=vs.85%29.aspx[^].
You only needsif you need to stop the user from navigating from your page (which is usually not very nice, by the way, but you can ask users confirmation and still allow to leave the page if the confirmation is given). See also this discussion: http://***.com/questions/3775566/javascript-question-onbeforeunload-or-onunload[^].
—SA