<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    
    <script src="script.js"></script>
  </head>

  <body>
    <h1>Hello World!</h1>
    
    <input type="button" value="Page 2" onclick="redirectToPage2();"/>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <div>By Balajiprasad</div>
  </body>

</html>
// Code goes here

function getReferrer(){
$(document).ready(function(){
  alert("Previous page is: " + document.referrer);
});
};

function redirectToPage2(){
  
  window.location.href  = "index2.html";
};
/* Styles go here */

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    
    <script src="script.js"></script>
  </head>

  <body onload="getReferrer();">
    <h1>Hello World! - Page2</h1>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <div>By Balajiprasad</div>
  </body>

</html>