Access history length property in Javascript

Description

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:

Example


<!DOCTYPE HTML> 
<html> 
    <body> 
        <script> 
            if (history.length == 0){ <!--from   w w  w .j  a v  a  2s . c om-->
                document.writeln("0")
            } else{
                document.writeln("more than 0")
            }


        </script> 
    </body> 
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window