0

I've been trying to get a single page application working on Chrome, Safari and Firefox but Firefox doesn't seem to be executing the window.onpopstate at all.

window.onpopstate = function() {
    fullpath = location.pathname;
    console.log(fullpath);
}

I have .htaccess routing all requests back to index.html so when the the client makes a request, the browser stores the url as a javascript variable and passes it through the js in index.html

When run in firefox, the variable isn't passed to the index.html page. Anyone have a solution or any suggestions for how to look deeper into this issue?

Emanegux
  • 1,000
  • 2
  • 17
  • 37

1 Answers1

2

From the Firefox popstate documentation:

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.

As epascarello says in his comment, initialize your variables in the load event and everything should work in Chrome/Safari and Firefox.

robertc
  • 69,665
  • 18
  • 184
  • 170
  • and I'm guessing a good call would be to have a hashtag fallback for IE? – Emanegux Jun 06 '13 at 02:16
  • @Emanegux If you have enough IE users to make it worth your while, then yes. Note that [IE10 has support](http://caniuse.com/history). – robertc Jun 06 '13 at 10:31
  • FireFox, IE10, etc. are exhibiting the HTML5 standards-compliant behavior. Up-vote https://code.google.com/p/chromium/issues/detail?id=63040 to push Google to fix Chrome. – Dave Dec 04 '13 at 21:23