Javascript:history.go (-1);

Source: Internet
Author: User
History is a collection of URLs (simply called URLs) of the pages you've browsed, which is the historical record in your browser. It is a built-in object in JS, just like document, it has its own method, go is one of them.

The parameter of this method is a number that specifies the index of the URL to locate relative to the current page URL location. The current URL is labeled 0, so Window.history.go (-1) is going to be positioned relative to the page labeled 1 on the current page, which is the page you just visited.

Let me give you an example:
You visit Baidu page in the Address bar (http://www.baidu.com), then the history of the address added to its collection, and will be calibrated to 0.
Through the search, you visited the Sina page (http://www.sina.cn), the browser put this URL in the history, and the site is calibrated to 0, and the previous visit to the Baidu page subscript relative to the visit of the Sina page has become-1.
If you go through the news link to open the NetEase page (http://www.163.com), the browser will be the same as on the NetEase into the history, subscript 0, and NetEase before a visit to the page Sina, in the history of the subscript will become-1, the same way Baidu's subscript becomes-2.



In a word, this code is just like the back button on your browser.

Javascript:history.go (-1);

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.