Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE9 and History.replaceState #55

Closed
pselden opened this issue Apr 27, 2011 · 4 comments
Closed

IE9 and History.replaceState #55

pselden opened this issue Apr 27, 2011 · 4 comments

Comments

@pselden
Copy link

pselden commented Apr 27, 2011

I'm trying to work out how to do AJAX based page redirects (my endpoint tells the page it needs to redirect through a json object). In order to make it so it behaves like a normal redirect, I need to discard the state from the history so that back button doesn't bring you back onto the redirected page, causing another redirect and effectively killing the back button.

It goes something like this:

$.getJSON(url, function(data){
  if(data.redirect){
     History.replaceState({}, "", data.redirect); // redirect is something like /users/1
     // trigger ajaxy redirect
  }
});

This works fine with HTML5 history browsers, but is having trouble with hashchange browsers (IE 9 is the one I've tested with). The back button still triggers the discared state to be hit. I stepped into the code and found that it's because of the way History.js handles the shortened urls to create the state hash. When the state is added to the discarded states, the hash is something like (assuming redirected page was the root url): '/', whereas when the back button is pressed, it compares it to the hash './'... so it doesn't think it's a discarded state.

Any ideas how to fix or work around this?

@balupton
Copy link
Member

Hey mate,

Can you provide a step by step set of what is happening - the urls/states that happened step by step, and the urls/states that you expected step by step - that'll really help, thanks :)

@pselden
Copy link
Author

pselden commented May 17, 2011

Trying to distill it down to a small reproduce-able test case... but unfortunately right now it's only occurring in my big bulky production code! I'll close this for now and re-open if I can figure out how to reliably reproduce.

@pselden pselden closed this as completed May 17, 2011
@dsadaka
Copy link

dsadaka commented Mar 12, 2012

I am having this same issue. Was it ever resolved?

@schellmax
Copy link

same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants