2013-01-10 79 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); 
} 
相关问题