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>