簡體   English   中英

Firefox的“后退”按鈕無法正常工作:顯示的是javascript,而不是html

[英]Firefox Back button not working as expected: javascript displayed instead of html

我正在使用History.js使我的Ajax頁面可添加書簽,並具有預期的后退/前進瀏覽器按鈕體驗。 在Safari中一切正常,但是在Firefox 6中,如果我離開站點,然后使用返回按鈕返回,則顯示的是JavaScript,而不是頁面:

  1. 轉到mysite.com/user/1/post_board
  2. 單擊帖子過濾器,將地址更改為mysite.com/user/1/post_board?filter=one
  3. 在地址欄中輸入google.com
  4. 按下后退按鈕
  5. 我看到在第2步加載了JavaScript

怎么了 我做錯了什么?

這是代碼:

//  Bind to StateChange Event
    History.Adapter.bind(window,'statechange',function(e)
    {
        var state = History.getState();
        eval(state.data.function_rest + "("+JSON.stringify(state)+");");        
        History.log(state);
    });


$('.message_filter').bind('click', function() 
    {
        History.pushState({"function_rest":"restore_post_board_widget"}, document.title, this.href);
        return false
    });

function restore_post_board_widget(state)
{   
    $.getScript(state.url);
}

謝謝你的幫助。

只需添加:

window.onunload = function(){};

這是我得到答案的地方:

返回Firefox歷史記錄后,JavaScript將無法運行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM