onclick
does exactly what you said. However, if you really don't want to use it, you can always do this:
<a id="link_id" href="javascript:location.reload()">link</a>
As exemplified by this snippet:
let i = 0;setInterval(() => {document.getElementById("span").innerHTML = i;i++}, 50);
<a href="javascript:location.reload()">link</a><br>
<span id="span"></span>
EDIT: Since you actually told me what you wanted in the comments, I present you with code!
Since you only have one element with the ID link_id
you can do any of the following:
<a id="link_id" href="http://link.com" onclick="location.reload()">link</a>
OR
document.getElementById("link_id").onclick = location.reload;
OR
document.getElementById("link_id").addEventListener("click", location.reload);
If you have multiple elements under one ID, you seriously need to reconsider your HTML knowledge
YET ANOTHER EDIT: as the air of mystery and vagueness unfolds, I see that you have multiple elements with one ID, or seem to. In that case, use class, and then do this:
Array.from(document.getElementsByClassName("<classname>")).forEach(el => {
el.addEventListener("click", () => {location.reload();});
});
I REALLY HOPE THIS IS THE FINAL EDIT - Replace <classname>
with the name of your class, of course
Array.from(document.getElementsByClassName("<classname>")).forEach(el => {
el.addEventListener("click", () => {
if (!sessionStorage.getItem("reloaded")) {
sessionStorage.setItem("reloaded", true);
location.reload();
}
});
});
Check out this jsfiddle - it works: https://jsfiddle.net/gbdu3vpm/1/