JavaScript BOM location object properties and methods


<!DOCTYPE html>

<html>

 <head>

  <title>Page Title</title>

 </head>

 <body>

  <h1>JavaScript : Location Object</h1>

  <button onclick="newFunction()">Set</button>

  <button onclick="reload()">Reload</button>

  <button onclick="assign()">Assign</button>

  <button onclick="replace()">Replace</button>


 <script>

  function newFunction()

  {

   location.href = "http://www.tesla.com";

  }

  function reload()

  {

   location.reload();

  }

  function assign()

  {

   location.assign("http://google.com");

  }

  function replace()

  {

   location.replace("http://google.com");

  }

 </script>

 </body>

</html>


OUTPUT





Comments