Reputation: 3862
Having trouble with history.js and this question and it's subsequent answers just created more questions for me.
Problem 1:
The popstate
and statechange
listeners seem to both be triggered by pushState()
and popState()
, which according to that answerer is by design?
I only want to listen for the popstate event, I know I can check by using the data parameter, but setting the data and title parameters to anything not null
adds a bunch of extra stuff in the hash in IE8/9, like this:
http://www.site.com/#about/?_suid=13383514298760299522541335484
I know I could create an extra var to take care of that, but I'd rather not.
Problem 2:
Also in IE8-9, how do you remove the hash for the main page, right now if I do
History.pushState(null, null, 'http://www.site.com');
The url turns out like this:
http://www.site.com/#http%2A//www.site.com
And if I do either of these:
History.pushState(null, null, '');
History.pushState(null, null, '/');
The url turns out like this:
http://www.site.com/#./
But I'd like the url to take any one of these formats:
http://www.site.com
http://www.site.com/
http://www.site.com/#
http://www.site.com/#/
I am using the jQuery history plugin.
Upvotes: 4
Views: 876
Reputation: 3752
I'm not sure about the answer to problem #1.
However, for problem 2, the issue is related to the capabilities of an HTML5 browser vs an HTML4 browser. From the documentation:
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.
Therefore, HTML4 browsers are stuck with the hash urls. Sorry.
Upvotes: 1