fortes / history.js

[Not Maintained!] HTML5 History APIs for legacy browsers. Implements window.history.pushState(), window.history.replaceState(), and the window.onpopstate event.
171 stars 12 forks source link

Firefox 3.6.8 sometimes doesn't define functions #2

Closed bcardarella closed 5 years ago

bcardarella commented 14 years ago

I cannot isolate why but it seems that Firefox will randomly not define the state functions on the history object. I see no debug messages in the console nor any error messages.

Kind of a poor bug report, but it's happening and I can only recreate it randomly. I'll try to gather more info.

bcardarella commented 14 years ago

I've confirmed the strange bug on two different systems and have detailed the bug report here: https://bugzilla.mozilla.org/show_bug.cgi?id=593910

Any thoughts would be welcome.

fortes commented 14 years ago

Thanks for doing the legwork here. I ran into this a couple of times with FF, but also had problems recreating it. Let me know if the Mozilla guys have a workaround, otherwise we may have to use wrapper functions for the API instead :(

bcardarella commented 14 years ago

That's pretty much what I ended up doing. In the code to call history.replaceState I just have a conditional that tests for its existence then calls changeState instead:

if (typeof(history.replaceState) == 'undefined') {
  changeState(obj, title, url);
} else {
  history.replaceState(obj, title, url);
}

Hope that helps others.

xcoderzach commented 14 years ago

Hey guys,
I think if you use window.History.prototype.replaceState = function() { //blah }

it should solve the problem

subtleGradient commented 13 years ago

Maybe you could use both? Use window.History.prototype.replaceState = and then fall back to window.history.replaceState = if that doesn't work.