Does Firefox handle [removed] differently than Chr

2019-09-16 09:38发布

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?

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-16 10:04

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.

查看更多
登录 后发表回答