2
我花了一些時間搜索,但一直未能找到這個問題的答案。當用戶在我的網站上執行某些操作時,會正確顯示jGrowl消息。但是,如果用戶刷新頁面,則意外重新顯示該消息。另外,當用戶離開頁面,然後按下瀏覽器的後退按鈕時,jGrowl消息意外顯示。如何防止頁面刷新時再次顯示jGrowl消息?
我已經在代碼中設置了一個斷點,它只在第一次遇到jGrowl消息時顯示。刷新頁面不會導致斷點被擊中。
那麼如何防止這種意外的行爲呢?謝謝你的時間。
我認爲這是一個很多人需要解決方案的問題。
<#escape x as x?js_string>
$(function(){
$("a[name=preview]").fancybox({type:'ajax'});
// We use jGrowl for the popups that appear in the corner
$.jGrowl.defaults.closer = false;
<#if confirmMessage??>
$("#jgrowlcontainer").jGrowl("${springMacroRequestContext.getMessage(confirmMessage)}");
</#if>
// Delete a program
$('#deleteProgram').click(function(){
$.fancybox.open('<p>Are you sure you want to delete this program?</p>'+
'<button id="deleteProgram">DELETE</button> <button id="deleteCancel">CANCEL</button>');
return false;
});
$("body").on("click","button#deleteCancel",function(){
$.fancybox.close();
});
$("body").on("click","button#deleteProgram",function(){
$.fancybox.close();
$('form').attr('action','/build/deleteProgram.html').submit();
return false;
});
});
</#escape>
你能提供一些你的代碼嗎? –
有問題的通知的「粘性」屬性是否設置爲false? – ktamlyn
有粘性是假的。 – r0144