I have the following code
$(document).ready(function() {
if ("onhashchange" in window) {
alert("The browser supports the hashchange event!");
}
function test(){
alert("hash has changed = " + window.location.hash)
}
window.onhashchange =test;
}
I click a link that changes the hash and in all other browsers I get the alert in test
However in IE I get the first alert saying it supports onhashchange but then when the hash changes nothing happens.
Any ideas?
There's an example on the MSDN doc page.
Basically, I removed all the extra "map" stuff on their page and the only difference between theirs and your example is that they include the following meta-tag:
I added this to the head tag in your example and it worked fine.
This meta-tag basically says to run the page as if it were in IE 8 and not IE 9 (which is still in beta).
For more information on this meta-tag read here