Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refreshing page on click of a button

Tags:

javascript

I would like to refresh the current page when a button is clicked.

Using JavaScript, I have the following:

<button type="button" onClick="refreshPage()">Close</button>  <script>     function refreshPage() {         // What do I put here?     }  </script> 

What would to code look like to refresh the current page?

like image 830
curiousgeorge Avatar asked Mar 30 '11 01:03

curiousgeorge


People also ask

How do I stop my page from reloading on button click?

To do not refresh the page we add event. preventDefault(); at the end of our JavaScript function.

How do I trigger a refresh page?

You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.

How do I refresh my screen with buttons?

Pressing the F5 function key can act as a keyboard shortcut to refresh the Windows desktop screen.

How do you refresh a page when a button is clicked?

reload() method gives the same result as pressing the reload button on your browser. This method reloads the page from directly the browser's cache by default.


1 Answers

<button type="button" onClick="refreshPage()">Close</button>  <script> function refreshPage(){     window.location.reload(); }  </script> 

or

<button type="button" onClick="window.location.reload();">Close</button> 
like image 165
amit_g Avatar answered Sep 20 '22 20:09

amit_g