files/en-us/web/api/navigation/cangoforward/index.md
{{APIRef("Navigation API")}}
The canGoForward read-only property of the
{{domxref("Navigation")}} interface returns true if it is possible to navigate forwards in the navigation history
(i.e., the {{domxref("Navigation.currentEntry", "currentEntry")}} is not the last one in the history entry list),
and false if it is not.
A boolean value: true if it is possible to navigate forwards in the navigation history, false otherwise.
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}}