2012-05-28 47 views
1

我想訪問瀏覽器使用jQuery的上一個或下一個按鈕。當我點擊瀏覽器上一個按鈕我想看到警報(「是」);或任何response.is有可能嗎?瀏覽器的上一個或下一個按鈕控件

+0

創建一個[演示](http://jsfiddle.net/DerekL/LZCj7/show/)。看看你是否仍然需要它。 –

回答

5

是的。它是(莫名其妙)可能在HTML5中。它不需要jQuery。爲此,使用onpopstate

MDN:https://developer.mozilla.org/en/DOM/window.onpopstate

window.onpopstate = function(event) { 
    alert("location: " + document.location); 
}; 

但爲了使用onpopstate,你將不得不使用pushState第一。

DEMO:http://jsfiddle.net/DerekL/LZCj7/show

PS:原本是AJAX應用程序做出。

替代方法:

<body onbeforeunload="return 'This is an alert.'"> 
+0

使用'onpopstate'和'pushState'時,按鈕的行爲不同。 –

相關問題