Make a custom button to reload the browser window

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>

Leave a Comment