Skip to main content

Here is an example of how to reload a page on button click with Javacript and removing the query string.

I have a page like this:

I want to be able to click a “Reset” button to start over by removing the query string:

Here is an example of how to do this:

<!DOCTYPE html>
        <a href="#" id="reload">Click to reload without query string</a>

            document.getElementById("reload").onclick = function() {reload()};

            function reload() {
                window.location = window.location.href.split("?")[0];

Demo it here

Leave a Reply