The History object provides information about the historical list, including the URLs of the 10 most visited pages1. Common Properties of History objectslength Returns the number of URLs in the browser history list<! DOCTYPE html>
<meta charset= "UTF-8" >
the Length property of the <title>history object </title>
<body>
</body>
<script>
document.write ("<li>" +history.length);
</script>
2. Common methods of History objects1) Back () methodThe function of this method is to display the previous page in the browser, equivalent to go ( -1)firstpage.html:<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> This is the first page of </title>
<body>
<span> This is the first page of </span>
<a href= "secondpage.html" > Go to the second page </a>
</body>
secondpage.html:<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> This is the second page </title>
<body>
<span> This is the second page </span>
<p><a href= "#" onclick= "Javascript:window.history.back ()" >back () return to the previous page </a></p>
<p><a href= "#" onclick= "Javascript:window.history.go ( -1)" >go (-1) Back to previous page </a></p>
</body>
diagram:
2) Forward () methodThe function of this method is to display the next page in the browser, equivalent to go (1)3) Go (int) methodThe function of this method is to load the page int from the current count (int is an integer) in the browser, and if int is negative, it is equivalent to return.
--javascript Foundation for the use of history objects