Bugzilla – Bug 18405
History API: Clearly define popstate event behaviour on page load
Last modified: 2012-09-18 23:07:31 UTC
Currently the spec for the new history API (history.pushState and popstate event, http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html) is ambigous about when to trigger a popstate event, at least ambigous enough for Chrome/Safari and Firefox to differ in a severe way (from an API user perspective).
The MDN article on popstate (https://developer.mozilla.org/en/DOM/window.onpopstate) puts it like this: "Browsers tend to handle the popstate event differently on page load. Chrome and Safari always emit a popstate event on page load, but Firefox doesn't."
I'd like to see this clearly defined in the spec, so that users can use the API without requiring libraries like History.js (https://github.com/balupton/History.js/).
Or custom workarounds like these:
Or unreliable timeouts:
Considering the workarounds, the right behaviour seems to be the one as implemented in Firefox: Don't trigger popstate on page load, as that is a distinct event anyway.
*** This bug has been marked as a duplicate of bug 18605 ***