files/en-us/web/api/navigation/back/index.md
{{APIRef("Navigation API")}}
The back() method of the
{{domxref("Navigation")}} interface navigates backwards by one entry in the navigation history.
back(options)
options {{optional_inline}}
info {{optional_inline}}
info.An object with the following properties:
committed
finished
intercept() handler are fulfilled. This is equivalent to the {{domxref("NavigationTransition.finished")}} promise fulfilling, when the {{domxref("Navigation/navigatesuccess_event", "navigatesuccess")}} event fires.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}}