![](/img/trans.png)
[英]How can I ask users to confirm before leaving the page on the Aurelia.js
[英]How can I ask users to confirm before closing the window with Aurelia.js app
因此,我想請用戶確認是否要在關閉瀏覽器之前離開頁面。 當他離開頁面時,僅當他關閉窗口時,我才顯示用戶消息框沒有問題。 這對我不起作用:
PLATFORM.global.addEventListener("beforeunload", this._beforeUnloadEventHandler);
而且, 此答案僅有助於解決問題。
這樣行嗎?
PLATFORM.global.addEventListener("beforeunload", () => this._beforeUnloadEventHandler());
與PLATFORM.global.addEventListener
相比,不確定jquery事件系統如何工作,但這是我使用的。
$(window).on('beforeunload', () => {
if (this.dirty) {
return 'Really leave?'; // return a string to ask the user. You can't stop it in any other way.
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.