iphone micro letter back problems are not refreshed

View ios solve a lot of micro-channel Returns to refresh the article page, most of them take advantage of new features in history H5 to be solved, but a lot of people's ideas are used pushstate and popstate to achieve this functionality, but after using pushstate adds a history entity, then listening to a time-triggered popstate time, refresh the page is refreshed, when in fact just added this entity, it will fall into an infinite loop, the user will not retreat this page or directly off the page. Following this approach a good solution to this problem.

$ ( Function () { 
        pushHistory (); 
    }); 
    function pushHistory () { 
        window.addEventListener ( "the popstate", function (E) {
     // listening here back to event 
            self.location.reload (); 
        }, to false ) ;
         var State = { 
            title: "" , 
            URL: "#" 
        }; 
        window.history.replaceState (State, "", "#" ); 
    };

Tips:

1.popState event only in the role of go (-1), will trigger back (), forward () and so on. 

2. Key is self.location.reload () ;, after Back to refresh the current page. Other people write articles in the absence of this one, I get very depressed. 

3. Micro letter after listening to iphone back events trigger popState event, performed PopState event in: self.location.reload (); to refresh the page after the retreat.

4.pustate increases the length of history, when the retreat to be wrong, often impossible to escape the cycle, and replace a good solution to this problem.

Guess you like

Origin www.cnblogs.com/yechangzhong-826217795/p/11701002.html