files/en-us/web/api/navigation/forward/index.md
{{APIRef("Navigation API")}}
The forward() method of the
{{domxref("Navigation")}} interface navigates forwards by one entry in the navigation history.
forward(options)
options {{optional_inline}}
info {{optional_inline}}
info.An object with the following properties:
committed
finished
Either one of these promises rejects if the navigation has failed for some reason.
InvalidStateError {{domxref("DOMException")}}
async function backHandler() {
if (navigation.canGoBack) {
await navigation.back().finished;
// Handle any required clean-up after
// navigation has finished
} else {
displayBanner("You are on the first page");
}
}
async function forwardHandler() {
if (navigation.canGoForward) {
await navigation.forward().finished;
// Handle any required clean-up after
// navigation has finished
} else {
displayBanner("You are on the last page");
}
}
{{Specifications}}
{{Compat}}