onhashchange with IE 9

前端 未结 3 785
春和景丽
春和景丽 2021-01-14 06:30

I have the following code

$(document).ready(function() {
   if (\"onhashchange\" in window) {
      alert(\"The browser supports the hashchange event!\");
           


        
3条回答
  •  离开以前
    2021-01-14 07:24

    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

提交回复
热议问题