Reputation: 440
I have a link with hash sign:
How do I enable page reload when its clicked?
Is it only possible with js?
Upvotes: 0
Views: 189
Reputation: 465
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;
Upvotes: 2