javascript – Button that refreshes the page on click-ThrowExceptions

Exception or error:

I need a button that will refresh the page on the user’s click.
I tried this:

<input type="button" value="Reload Page" onClick="reload">


<input type="button" value="Refresh Page" onClick="refresh">

But neither worked.

How to solve:

Use onClick with window.location.reload(), i.e. :

<button onClick="window.location.reload();">Refresh Page</button>

Or history.go(0), i.e.:

<button onClick="history.go(0);">Refresh Page</button>

Or window.location.href=window.location.href for ‘full‘ reload, i.e.:

<button onClick="window.location.href=window.location.href">Refresh Page</button>

The Button element –


This works for me


    <button type="submit"  onClick="refreshPage()">Refresh Button</button>


function refreshPage(){


<a onClick="window.location.reload()">Refresh</a>

This really works perfect for me.


Only this realy reloads page (Today)

<input type="button" value="Refresh Page" onClick="location.href=location.href">

Others do not exactly reload. They keep values inside text boxes.


button that refresh the page on click

Use onClick button with window.location.reload():

<button onClick="window.location.reload();">


<button onclick=location=URL>Refresh</button>

This might look funny but it really does the trick.


just create the empty reference on link such as following

 <a href="" onclick="dummy(0);return false;" >


Use this its work fine for me to reload the same page:

<button onClick="window.location.reload();">


I noticed that all the answers here use inline onClick handlers. It’s generally recommended to keep HTML and Javascript separate.

Here’s an answer that adds a click event listener directly to the button. When it’s clicked, it calls location.reload which causes the page to reload with the current URL.

const refreshButton = document.querySelector('.refresh-button');

const refreshPage = () => {

refreshButton.addEventListener('click', refreshPage)
.demo-image {
  display: block;
<button class="refresh-button">Refresh!</button>
<img class="demo-image" src="">


If you are looking for a form reset:

<input type="reset" value="Reset Form Values"/>

or to reset other aspects of the form not handled by the browser

<input type="reset" onclick="doFormReset();" value="Reset Form Values"/>

Using jQuery

function doFormReset(){


window.opener.location.href ='workItem.adm?wiId='+${param.wiId};

It will go to the required path and you won’t get any resend prompt.

Leave a Reply

Your email address will not be published. Required fields are marked *