[Browser] Properties and methods of the History object

Attributes

1. length attribute

Definition: The length attribute declares the number of elements in the browser history list.
Syntax: history.length
Example:

console.log(history.length)//输出结果:历史列表中元素的数量

method

1.back()

Function: The back() method can load the previous URL in the history list (if it exists).
grammar:history.back()

2.forward()

Function: Load the next URL in the history list.
grammar:history.forward()

3.go()

Function: Load a specific page in the history list.
Syntax: history.go(number|URL)
The parameter can be a number, and the relative position of the URL to be accessed in the URL list of History is used. (-1 goes up one page, 1 goes one page forward). Or a string, the string must be a partial or complete URL, this function will match the first URL in the string.

Guess you like

Origin blog.csdn.net/m0_46533551/article/details/129522439