onHashChange buggy in IE6 & IE7

I’m programming my own Ajax history library in JS. I ran into problems with IE6 and IE7. I wish to learn why the following are happening before I download some huge library that implements Ajax history.

IE6 & 7

I am able to set the hash values without refreshing the page.


window.location = 'site.com/index.html#' + pageNumber;

I can go to page 1, page 2, page 3, and so on. When I’m on page 3 and hit the back button, I’m not transported back to page 2. Rather, I get completely taken out of index.html! It seems like IE does not think that different hash values are different points in history.

IE7

IE8 in IE7 backwards compatibility mode claims that it has the onhashchange listener.


if ('onhashchange' in window) {
   // true in IE7
   window.onhashchange = someFunction();
}

However, IE7 never executes someFunction() when the URL changes. This implies that it lies about having onhashchange but never implemented it.