Different ways to Refresh Webpage using JavaScript
Document API
The document interface represents any webpage loaded in the browser & serves as an entry point into the web page's content which is the DOM tree.
document.location.reload();
Windows API
The window interface represents a window containing a DOM document. The document property points to the DOM document loaded in that window.
window.location.reload();
Refresh Using Button
We can create a button with the onClick attribute that will trigger the website reload as the reload() function is passed.
<button
type="button"
onClick="window.location.reload()">
Click to Refresh
</button>
Using SetTimeout()
This method calls a function after several milliseconds.
setTimeout(() => {
document.location.reload();
},10000);
History API
The DOM window object provides access to the browser's session history through the history object.
history.go();