Make a custom button to reload the browser window

Date Published: 02/09/2020 Published By: JaiSchool

Use location.reload() or window.history.go(0) to reload webpage.

<!DOCTYPE html>
<html>
<head>
  <title>reload</title>
</head>
<body>
  <button id="btn">Click on me to reload the webpage!!!</button>
<script>
  var btn=document.getElementById("btn");
  btn.onclick=function()
  {
    window.history.go(0);
  }
</script>
</body>
</html>

Or use reload() method

<!DOCTYPE html>
<html>
<body>
  <button id="btn">Reload</button>
<script>
  var btn=document.getElementById("btn");
  btn.onclick=function()
  {
    location.reload();
  }
</script>
</body>
</html>

Publish A Comment

Leave a Reply

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