Home > Web Front-end > JS Tutorial > body text

How to use javascript history object (history record) (implementing browser forward and backward)_Basic knowledge

WBOY
Release: 2016-05-16 17:05:04
Original
2143 people have browsed it

The window.history object does not need to use the window prefix when writing. To protect user privacy, JavaScript's methods of accessing this object are restricted.

Method:

history.back() - Loads the previous URL in the history list, this is the same as clicking the forward button in the browser
history.forward() - Loads the next URL in the history list, this is the same as clicking the forward button in the browser Clicking the forward button in the browser is the same

Example:

Copy code The code is as follows:



Copy code The code is as follows: history.go(0);//Refresh the current page
//The following must have a history record in the browser, otherwise it will not be effective.
history.go(1);//Go forward one page
history.go(-1);/ /Go back one page
history.go(-2);//Go back two pages
history.length;//Number of history records contained in the current window


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template