Listener browser's Back

Listener browser back (without adapter)

Note: computer phone Google browser does not apply, only occasionally successful. Find the problem Google browser requires the user to enter the page there are interactive, such as post-click browser back listeners to take effect, but the computer 360 browser will now be directly monitor

1. Code browser history will be written into a history and press forward to this

history.pushState({title: 'vigoo', url: window.location.href}, null); 

2. browser back by listening, listening to when browser history has a step back

window.onpopstate = function (event: any) {

   alert(document.location + ", state: " + JSON.stringify(event.state));  };

3. Detailed Description: First, each page will be pushed into a history and listening back, after listening to Back: Click OK to call history.back (); (This method calls the listener less), click Cancel pressed into a history. This completes the browser back pop listener to retain customers

Guess you like

Origin www.cnblogs.com/dlm17/p/12345404.html