Skip to content

Latest commit

 

History

History
61 lines (40 loc) · 1.17 KB

index.md

File metadata and controls

61 lines (40 loc) · 1.17 KB
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.

Syntax

forward()

Parameters

None.

Return value

None ({{jsxref("undefined")}}).

Examples

The following examples create a button that moves forward one step in the session history.

HTML

<button id="go-forward">Go Forward!</button>

JavaScript

document.getElementById("go-forward").addEventListener("click", (e) => {
  history.forward();
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also