title | slug | page-type | browser-compat |
---|---|---|---|
History.forward() |
Web/API/History/forward |
web-api-instance-method |
api.History.forward |
{{APIRef("History API")}}
The History.forward()
method causes the browser to move
forward one page in the session history. It has the same effect as calling
{{domxref("History.go", "history.go(1)")}}.
This method is {{glossary("asynchronous")}}. Add a listener for the {{domxref("Window/popstate_event", "popstate")}} event in order to determine when the navigation has completed.
forward()
None.
None ({{jsxref("undefined")}}).
The following examples create a button that moves forward one step in the session history.
<button id="go-forward">Go Forward!</button>
document.getElementById("go-forward").addEventListener("click", (e) => {
history.forward();
});
{{Specifications}}
{{Compat}}
- {{domxref("History")}}
- {{domxref("Window/popstate_event", "popstate")}}
- Working with the History API