Reputation: 4264
I have the below code.
<button id="RefreshMe">Refresh Page</button>
<script>
jQuery('#PageRefresh').click(function() {
location.reload();
});
</script>
This works fine however my page has some hidden values in a form so instead of reloading www.example.com it reloads www.example.com?a=111 etc which is causing an error as the uri is to big. I want the user to go back to www.example.com rather than www.example.com?a=111 what else needs to be added?
Upvotes: 0
Views: 2930
Reputation: 2200
A better answer is this:
history.pushState({}, 'title', '/');
This will refresh the page with no params and no path (basically your home page). But let's say you have a non-home page, such as:
yoursite.com/pricing?myparam=shazam
If you want to just remove the param, you'd do this:
history.pushState({}, 'title', '/pricing');
And you'd end up with this:
yoursite.com/pricing
Upvotes: 1