19

リロードせずにhtmlを変更したい。私はそれを次のようにします:

$('#left_menu_item').click(function(e) {
    if (!!(window.history && history.pushState)) {
        e.preventDefault();
        history.pushState(null, null, newUrl);
    }
});

正しく動作します。しかし、「戻る」ボタンで戻りたい場合-ブラウザは前のURLを変更しますが、ページをリロードしません。なんで?

4

2 に答える 2

13
window.onpopstate = function(event) {    
    if(event && event.state) {
        location.reload(); 
    }
}

これは私が使用するものです:)

于 2014-02-02T07:02:58.900 に答える