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

window.location.replace not working on chrome ( 34 ) #63

Closed
cagosta opened this issue Apr 29, 2014 · 6 comments
Closed

window.location.replace not working on chrome ( 34 ) #63

cagosta opened this issue Apr 29, 2014 · 6 comments
Labels

Comments

@cagosta
Copy link

cagosta commented Apr 29, 2014

Hey,

I use Hasher and for about two weeks my back button does not work anymore one my application. I have investigated and found that window.location.replace causes history to be completely lost. After using location.replace, when using back button, the page completely reload.

On any page, if you do this:

// on https://github.com/#foo
window.location.hash = '#bar'  // uri https://github.com/#bar
window.history.back() // uri  https://github.com/#foo

But if you do this:

// on https://github.com/#foo
window.location.hash = '#bar'  // uri https://github.com/#yo
window.location.replace('#baz ') // uri https://github.com/#bar 
window.history.back() // uri  https://github.com/, the all page reload 

Am I wrong ? Can somebody reproduce the bug ?

I'm running Chrome 34.0.1847.116 on Ubuntu 13.04
Everything is fine on Safari and Firefox.

As a solution, I have replaced the window.location.replace by window.history.replaceState but it works for modern browsers only.

@millermedeiros
Copy link
Owner

location.replace doesn't save the previous hash on the history (it overwrites the previous URI), so multiple consequent location.replace calls will save only 1 state on the history (just the last one).

if you need to go back and forward you should use hasher.setHash instead of hasher.replaceHash

@millermedeiros
Copy link
Owner

ohhh.. now I see what you're talking about.. it's probably a chrome bug. this error does reproduce on the unit tests: http://millermedeiros.github.io/Hasher/test/unit.html

@cagosta
Copy link
Author

cagosta commented Apr 29, 2014

yes, on my chrome tests do not pass and the page ( randomly ? ) reloads.
This should be a chrome bug.

@millermedeiros
Copy link
Owner

It was reported to chrome: https://code.google.com/p/chromium/issues/detail?id=330943

Let's keep this issue open (so other users know what is going on) and star the chrome bug so that it gets more attention. Thanks for reporting it.

@cagosta
Copy link
Author

cagosta commented Apr 29, 2014

Yes, this issue was mainly created to inform you and hasher's users of this.

Thank you

@millermedeiros
Copy link
Owner

this should be fixed now: https://code.google.com/p/chromium/issues/detail?id=363724

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

No branches or pull requests

2 participants