Skip to content Skip to sidebar Skip to footer

Browser's Previous Or Next Button Control

i want to access browser previous or next button using jQuery.When i click browser previous button i want to see alert('yes'); or any response.is it possible?

Solution 1:

Yes. It is (somehow) possible in HTML5. It does not require jQuery. Use onpopstate for that.

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

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

But in order to use onpopstate, you will have to use pushState first.

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

PS: it is originally made for AJAX applications.

Alternative method:

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

Post a Comment for "Browser's Previous Or Next Button Control"