JavaScript > Methods

Refreshing current page in JavaScript

How to reload/refresh current page in JavaScript?


In case we want to refresh the current page using JavaScript, we can follow this approach.

    <script>
        document.write(new Date());
        function TestFunction() {
            location.reload();
        }
    </script>

    <input type="button" id="btnReload" value="Reload" onclick="TestFunction()" />

In the above code on click of the button, we are executing “TestFunction” function. Inside this function we are calling the location.reload() method that reloads the current page.

OUTPUT

 Views: 4276 | Post Order: 55



Write for us






Hosting Recommendations