2013-01-10 99 views
1

如何使用History.js重新加載頁面(再次單擊相同/活動頁面/鏈接時)?歷史記錄 - 無法重新加載頁面(點擊同一鏈接)

當您在菜單欄中導航到/home,並且頁面完成加載後,再單擊/home頁面不會重新加載?

https://github.com/browserstate/History.js/

History.pushState(data, title, url); 

當點擊相同的鏈接再次頁面沒有加載?無法弄清楚爲什麼?

也試過用replaceState()方法

+0

這聽起來像您的瀏覽器緩存的網頁,只是重新加載存儲的頁面,當您導航回到它。 – RGdev

+0

我不會回去..我點擊相同的鏈接,頁面不會重新加載 – clarkk

回答

1
var currentLocation = document.location.pathname + decodeURIComponent(document.location.search); 
if (currentLocation == url) { 
    console.log("Refresh"); 
    $(window).trigger('statechange'); 
} else { 
    History.pushState(null, title, url); 
} 
相關問題