我如何强制页面重新加载链接与散列符号? [英] How do I force page reload in a link with hash sign?
本文介绍了我如何强制页面重新加载链接与散列符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能做到这一点?启用页面重新加载时,它的点击?
它是唯一可能与js?
解决方案
你必须听取HashChangeEvent并向位置搜索对象添加查询参数(如时间戳):
function locationHashChanged(){
var dstringquery =`d = $ {new Date()。getTime()}`;
location.search = location.search.length === 0? dstringquery:(location.search +'&'+ dstringquery);
}
window.onhashchange = locationHashChanged;
I have a link with hash sign:
How do I enable page reload when its clicked?
Is it only possible with js?
解决方案
You have to listen to the HashChangeEvent and add a query param (like a timestamp) to the location search object:
function locationHashChanged() {
var dstringquery = `d=${new Date().getTime()}`;
location.search = location.search.length === 0 ? dstringquery : (location.search + '&' + dstringquery);
}
window.onhashchange = locationHashChanged;
这篇关于我如何强制页面重新加载链接与散列符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文