Reputation:
On the current page, add button "Refresh".
Process: when the user clicks this button "Refresh", then this page link "https://abc.io/123" refreshes and do not open this link (not new page), still stay on the current page.
My code doesn't work:
<a href="https://abc.io/123" onClick="window.location.reload();return false;">
<i class="fas fa-sync-alt fa-1.5x" aria-hidden="true" style="color:#0000FF;"></i><span style="color:blue;"> Refresh</span>
</a>
How can I do it?
Upvotes: 0
Views: 752
Reputation: 9284
First of all onClick
should be onclick
. This will reload the page, except if the DOMException gets thrown, which blocks the reload. You can read more about it here.
By default, the page gets reloaded from the browser cache. To force reload it from the server, pass true
to window.location.reload()
.
<a href="https://abc.io/123" onclick="window.location.reload(); return false;">
<i class="fas fa-sync-alt fa-1.5x" aria-hidden="true" style="color:#0000FF;"></i><span style="color:blue;"> Refresh</span>
</a>
If you intend to open the link as well, return true
from the onclick function.
Upvotes: 0