2012-07-25 55 views
1

我以下列方式使用History.js jQuery的觸發不必要的「警報」(V1.7.1,HTML4 + HTML5束)在我的js的頂部History.js的jQuery在IE7

準備文件:

(function(window,undefined){ 

    // Prepare 
    var History = window.History; // Note: We are using a capital H instead of a lower h 
    if (!History.enabled) { 
     // History.js is disabled for this browser. 
     // This is because we can optionally choose to support HTML4 browsers or not. 
     return false; 
    } 

    // Bind to StateChange Event 
    History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate 
     var State = History.getState(); // Note: We are using History.getState() instead of event.state 
     History.log(State.data, State.title, State.url); 
    }); 

})(window); 

然後在我的代碼進一步下跌:

$foo.click(function(e) { 
     e.preventDefault(); 
     History.pushState({}, "", "?" + bar); 
    }); 

基本上我想要實現的是,每次被點擊某些項目時,查詢字符串"?" + bar追加到URL和推什麼State將其存儲在瀏覽器歷史記錄中。這工作完全正常的FF最新的,但在IE7測試時,出現以下警告類似的新消息:

History.js error in IE7 在彈出的網址是一個我很期待,即使在瀏覽器中顯示爲

http://www.foobar.com/.../#?Fixed 

即帶額外散列。但是,我擔心的是錯誤信息 - 任何線索?

回答

0

只是爲了記錄,如果有人再次發生在這個頁面上 - 我已經隔離了腳本,錯誤不再發生。經過漫長而乏味的測試,我發現它是由與專有的jquery插件衝突引起的,並對其進行了修復。

0

原因:您需要從代碼中刪除'History.log()'...在IE中,此History.log正在將警報輸出寫入警報箱...