Advertisement
jiue123

Action when browser back() or JS history.back()

Dec 7th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.84 KB | None | 0 0
  1. "popstate"
  2. IN THIS ARTICLE
  3. General info
  4. Properties
  5. Browser compatibility
  6. Example
  7. Related Events
  8. The popstate event is fired when the active history entry changes. If the history entry being activated was created by a call to history.pushState() or was affected by a call to history.replaceState(), the popstate event's state property contains a copy of the history entry's state object.
  9.  
  10. Note that just calling history.pushState() or history.replaceState() won't trigger a popstate event. The popstate event is only triggered by doing a browser action such as a click on the back button (or calling history.back() in JavaScript).
  11.  
  12. Browsers tend to handle the popstate event differently on page load. Chrome (prior to v34) and Safari always emit a popstate event on page load, but Firefox doesn't.
  13.  
  14. $(window).on("popstate", function(){
  15.     alert(1);
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement