How to use History Object in JavaScript

In this article I am going to explain about history object in JavaScript.
  • 1099

JavaScript History Object

JavaScript history object contain information about url visit by user on current browser window. Window object contain to history object and history object is the part window object (Window.history).

Syntax

history.length

Example

<html>

<head>

    <script type="text/javascript">

        function Backurl() {

            window.history.back()

        }

    </script>

</head>

<body>

    <button onclick="Backurl()">

        click me</button>

    <h3>

    No privious Url in histry list</3>

</body>

</html>

Example //This example will return number of visited url by user

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            document.write("Visit Url :- " + history.length);

        }

    </script>

</head>

<body>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

Output

nourl.jpg

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.