HTML DOM History length Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM History length property returns of URLs in the History list of current window.

Syntax

Following is the syntax −

history.length

Example

Let us see an example of HTML DOM History length property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
   body{
      text-align:center;
   }
   .btn{
      background-color:lightblue;
      border:none;
      height:2rem;
      border-radius:50px;
      width:60%;
      margin:1rem auto;
   }
   .show{
      font-size:2rem;
      font-weight:bold;
      color:orange;
   }
</style>
</head>
<body>
<h1>History length Property Example</h1>
<button type="button" onclick="getHistoryLength()" class="btn">Click me to get History length
<div class="show"></div>
<script>
   function getHistoryLength(){
      var historyLength=history.length;
      document.querySelector(".show").innerHTML = historyLength;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Click on the “blue” button to see the history length of current browser window.

raja
Published on 16-Jul-2019 17:06:30
Advertisements