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:
- go to mysite.com/user/1/post_board
- click on post filter, address changes to mysite.com/user/1/post_board?filter=one
- enter google.com in address bar
- push the back button
- 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
精彩评论