Javascript:window.history.go (-1) What does that mean?
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 also put this site in the history, and the site of the next calibration of 0, The previous visit to the Baidu page subscript relative to this visit Sina page becomes -1.
If you then open the netease page through the news link (http://www.163.com), the browser will be the same as on the NetEase in the history, subscript 0, and netease before a visit to the page Sina, in the history of the subscript has become-1, the same as Baidu's subscript becomes -2.
At this time, you through the Window.history.go (-1) statement, you can make the page to the current page of the previous page, that is, Sina , if you are using Window.history.go (-2), you can directly reach the Baidu page.
In a word, this code is just like the back button on your browser .
Javascript:window.history.go (-1) What does that mean?