location.reload() reloads the current URL. The simplest form is:
location.reload();
The original demo button is preserved, with the event handler moved out of inline HTML.
const button = document.getElementById('refreshButton');
button.addEventListener('click', () => location.reload());
You can move to the previous page using a Back button
The original example refreshed a child window referenced by tm. Keep the reference and check it before accessing it.
if (tm && !tm.closed) {
tm.location.reload();
tm.focus();
}
You can also read how to refresh the parent window from a child window.
JavaScript location Getting hostname Full URL
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.