cowboy / jquery-hashchange

This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser HTML5 window.onhashchange event.
http://benalman.com/projects/jquery-hashchange-plugin/
GNU General Public License v2.0
1.21k stars 258 forks source link

IE8 does not add manual hash changes to history #26

Closed justinjstark closed 8 years ago

justinjstark commented 11 years ago

This is something that could be added to make things more consistent across browsers.

While I do not expect the hashtag to be changed manually, it can happen. When it does, no history item is stored in IE 8. In firefox, the history item is stored and the back button works.

(1) Load a page in IE8. (2) Manually change the hashtag (or append one). (3) No item is added to the browser history.

I used the following code for testing.

$(window).hashchange(function(){
    alert(location.hash);
});
$(window).hashchange();
justinjstark commented 11 years ago

An easy fix is to always include the hidden iframe in internet explorer. The following change fixes this issue.

supports_onhashchange = 'on' + str_hashchange in window && (!$.browser.msie);