Create a button to go back two pages:
<button onclick="history.go(-2)">Go Back 2 Pages</button>
The output of the code above will be:
Click on Go Back to see how it works.
(Will only work if the previous pages exist in your history list)
The history.go()
method loads a URL (page) from the history list.
The history.go()
method only works if the page exist in the history list.
history.go(0)
reloads the page.
history.go(-1)
is the same as history.back()
.
history.go(1)
is the same as history.forward()
.
history.go(
number)
Parameter | Description |
number | Required. Negative values go back. Positive values go forward. |
NONE |
history.go()
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!