history.length

history.length tells how many items are in the history stack.

By testing for this value, it's possible to determine if the user's start point was your page:

 
<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
    </head> 
    <body> 
        <script> 
            if (history.length == 0){ 
                document.writeln("0")
            } else{
                document.writeln("more than 0")
            }


        </script> 
    </body> 
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    DOM  

History:
  1. The History Object
  2. history.back()
  3. history.forward()
  4. history.go(url/number)
  5. history.length
  6. history.pushState:Adding an Entry to the Browser History