开发者

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

开发者 https://www.devze.com 2023-04-04 14:25 出处:网络
I am using History.开发者_如何学Pythonjs to make my ajax pages bookmarkable and to have the expected back/forward browser button experience. In Safari all works great but in Firefox 6 if I leave my si

I am using History.开发者_如何学Pythonjs to make my ajax pages bookmarkable and to have the expected back/forward browser button experience. In Safari all works great but in Firefox 6 if I leave my site and then go back using hte back button I get the javascript instead of the page:

  1. go to mysite.com/user/1/post_board
  2. click on post filter, address changes to mysite.com/user/1/post_board?filter=one
  3. enter google.com in address bar
  4. push the back button
  5. I see the javascript loaded at step 2

What is going? What I am doing wrong?

Here is the code:

//  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);
}

Thanks for any help.


just add:

window.onunload = function(){};

this is where I got the answer:

After travelling back in Firefox history, JavaScript won't run

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号