Closed willianpts closed 10 years ago
Is this the expected behavior?
Yes, for IE9 and other HTML4-browsers
Sorry to comment on a closed issue, but I'm confused by this behavior too. It seems like an extra # is being added to the url on IE8.
I'm using the script on a one-page site that I'm creating. My code loads history.iegte8.min in a conditional statement for <IE9, then I have a function on the page that basically hi-jacks the links on the page and adds a nice animated scroll effect:
$("a[href^=#]").on("click", function(e) {
e.preventDefault();
var curHref = $(this).attr("href"), newPos = $(curHref).offset().top, curPath = window.location.pathname;
if (curPath.length < 2) {
history.pushState(null, null, "index.php"+curHref);
} else {
history.pushState(null, null, curHref);
};
$('html, body').animate({
scrollTop: newPos
}, 500);
});
It's simple and works perfectly well EXCEPT that the urls look like this:
http://imageaccent.com/#/index.php#about with an extra /# inserted in them
How it works in all other browsers where the pushState is natively supported is:
http://imageaccent.com/index.php#about
This is how I would expect the url to be returned.
Is this a bug?
Test page url: "http://127.0.0.1/test/home"
//then on IE9 console we try history.pushState({}, '', "profile");
At this point location.hash equals "#/profile" and browser url changes to "http://127.0.0.1/test/home#/profile".
Is this the expected behavior?