![](/img/trans.png)
[英]How to show a javascript confirmation box on “WordPress menu” before leaving the website
[英]leaving my website show popup box with message
當有人試圖離開我的網站時,我想向他們顯示彈出消息。 我嘗試使用window.onbeforeunload
函數,但它不起作用。
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit(){
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
嗨喬納森,我想在彈出窗口中顯示我的自定義消息。 當前它顯示默認消息 - 此頁面要求您確認您要離開 - 您輸入的數據可能不會被保存
嘗試這個。
$(window).bind('beforeunload', function() {
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
});
你的核心的第二行有問題
它應該是 :
window.onbeforeunload=confirmExit();
您的行缺少括號()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.