Return back, click the Back button monitor implementation code:
window.addEventListener("popstate", function(e) { alert ( "I listen to the browser's back button event friends"); // realize their functions according to their needs }, false);
While we listen back to the event, but will return to the previous page or a page, so we need to use a pushState increase the page url, on behalf of the page, it is very clear that #
function pushHistory() { was state = { title: "title", url: "#" }; window.history.pushState(state, "title", "#"); }
When entering this page, we'll give this history is pressed into a local connection. When you click to return, back and previous operations, it listens, listens to achieve their operation in the code.
Here is the complete code:
$(function(){ pushHistory(); window.addEventListener("popstate", function(e) { alert ( "I listen to the browser's back button event friends"); // realize their functions according to their needs }, false); function pushHistory() { was state = { title: "title", url: "#" }; window.history.pushState(state, "title", "#"); } });
PC side browser using jquery to listen:
$(document).ready(function(e) { was counter = 0; if (window.history && window.history.pushState) { $(window).on('popstate', function () { window.history.pushState('forward', null, '#'); window.history.forward(1); window.location.href = '/ PF_ECP / po / kefumishu.shtml'; // jump to individual centers }); } window.history.pushState ( 'forward', null, '#'); // have to have two rows in IE window.history.forward(1); });