Press "Enter" to skip to content

History Examples in JavaScript

Definition :

History object represents an array of URLs visited by the user. by using this object you can load previous, forward or any particular page. The history object is the window property, so it can be accessed by: window.history

Program 1  :

<html>

   <head>

      <script language=”javascript”>

                     function display()

                                 {

                                 //history.back();

                                 history.go(-1)

                                 //history.forward()

                                 }

                                 </script>

                                 </head>

                                 <body>

                                 <input type=”button” value=”Back” onclick=”display()”/> </br>

                                 </body>

</html>

Program 2 :

<html>

   <head>

      <script language=”javascript”>

                     function display()

                                 {

                                 window.location=”history1.html”;

                                 }

                                 </script>

                                 </head>

                                 <body>

                                 <input type=”button” value=”Add” onclick=”display()”/> </br>

                                 </body>

</html>

Be First to Comment

    Leave a Reply

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