--javascript Foundation for the use of history objects

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.