browserstate / history.js

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.
http://browserstate.github.com/history.js/demo/
Other
10.74k stars 1.35k forks source link

History.replaceState() Behavior different in chrome and IE8 #435

Open toni-moreno opened 9 years ago

toni-moreno commented 9 years ago

supose we are in this url.

http://myexample.com?param1=val1&param2=val2

and I set:

History.replaceState(null,null,"http://myexample.com?param3=val3");

On chrome:

URL changes to "http://myexample.com?param3=val3"

(as I wish)

On IE8:

URL changes to "http://myexample.com?param1=val1&param2=val2#?param3=val3"

history.js attach the new parameter on the old URL, prepended with "#" instead of substitute completely.

How can I fix that ?

gkrasulya commented 9 years ago

You can't, IE8 doesn't support History API.

You can redirect IE8 from http://myexample.com?param1=val1&param2=val2 to http://myexample.com#param1=va1&param2=val2 if you want. So in your example replaceState will change this url http://myexample.com#param1=va1&param2=val2 to http://myexample.com#param3=val3

toni-moreno commented 9 years ago

I don't understand what you mean.

Are you saying that I can do what I with if I use "#" instead of "?" as separator for URL and Query String?

gkrasulya commented 9 years ago

Of course, it's not the same. History.js fallbacks to hash if browser doesn't support History API.

Browsers dont send hash part of url to server. So in IE8 you need to check hash on page load and send ajax request to server to get actual data.