English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
go()method to load a specific URL from the history list.
If you know the specific page number or URL of the page to be loaded from the history record, usehistory.back()andhistory.forward()The method is a better choice.
history.go(number|URL)
<button onclick="history.go(-2);">Go 2 pages back</button>Test and See‹/›
The following output will be displayed by the above code:
All browsers fully support the go() method:
Method | |||||
history.go() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
number|URL | The parameter can be a number to navigate to a URL at a specific position (-1Go Back One Page,1Go Back One Page) or a string. The string must be a partial or complete URL, and the function will navigate to the first URL that matches the string. |
Return Value: | None |
---|
Go Forward One Page (This example does not work if there is no next page in the history record list):
<button onclick="history.go(1);">Load the Next URL</button>Test and See‹/›
History Record Reference:history.forward() Method
History Record Reference:history.back() Method