2012-07-05 109 views
7

我想讓history.js在Internet Explorer中工作,因爲我需要history.pushState()才能工作。我已經閱讀了GitHub上的說明(https://github.com/browserstate/History.js/),並試圖實現它,但沒有取得任何成功。 這裏就是我有History.js不能在Internet Explorer中工作

<!DOCTYPE html> 
<html> 
<head> 
    <!-- jQuery --> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
    <!-- History.js --> 
    <script defer src="http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script> 
    <script type="text/javascript"> 
     function addHistory(){ 

      // Prepare 
      var History = window.History; // Note: We are using a capital H instead of a lower h 

      // Change our States 
      History.pushState(null, null, "mylink.html"); 
     }  
    </script> 
</head> 
<body> 
    <a href="mylink.html">My Link</a> 
    <a href="otherlink.html">Other Link</a> 
    <button onclick="addHistory()" type="button">Add History</button> 
</body> 

不知道我在做什麼錯,但它絕對不是IE8或IE9工作。它可以在Firefox中工作,但這可能是因爲Firefox實際上支持history.pushstate。任何幫助表示讚賞

+1

是它的工作其他地方,或者你只嘗試IE? – Tyrsius 2012-07-05 21:14:13

+0

每個版本的IE或你嘗試過什麼版本? – 2012-07-05 21:22:58

+0

我已經試過IE8和IE9,對不起,離開了。它適用於Firefox,但這可能是因爲它默認支持history.pushstate? – Wilcoholic 2012-07-05 21:31:55

回答

1

在第二個<script>標記刪除詞defer
因爲,如果你提到這個詞,這意味着推遲。 (如果您想從中減少頁面渲染阻塞,請不要將其刪除)。這也是IE非常嚴格,這就是爲什麼你有這個問題。希望它可以幫助

參考this

相關問題