使用Ajax,並試圖使用.document對象創建實際的Ajax頁面上popstate事件處理程序:的addEventListener(「popstate」)未燒製.document
document.addEventListener("popstate", myPopState);
不幸的是,這並不永遠似乎觸發。
我的意圖是,頁面重新加載後,popstate事件觸發器會自動消失。
使用Ajax,並試圖使用.document對象創建實際的Ajax頁面上popstate事件處理程序:的addEventListener(「popstate」)未燒製.document
document.addEventListener("popstate", myPopState);
不幸的是,這並不永遠似乎觸發。
我的意圖是,頁面重新加載後,popstate事件觸發器會自動消失。
阿賈克斯成功響應裏面,你可以使用
var msg="Any thing which u want";
var customUrl ="www.stackoverflow.com";
window.history.pushState({"html":msg,"pageTitle":"My Title"},"", customUrl);
window.onpopstate = function(event) {
alert('back is clicked');
// what ever u want
}
UPDATE
$(window).unload(function(e){
e.preventDefault();
$(window).trigger('beforeunload');
});
$(window).bind('beforeunload',function(){
alert('call your ajax here');
return '';
});
'window.addEventListener( 「popstate」,myPopState);' – zer00ne