The traverseTo() method of the Navigation interface navigates to the NavigationHistoryEntry identified by the given key.
traverseTo(key)
traverseTo(key, options)
An object with the following properties:
committed -
A Promise which will fulfill when the visible URL has changed and a new NavigationHistoryEntry has been created.
finished -
A Promise which will fulfill when all promises returned by the intercept() handler are fulfilled. This is equivalent to the NavigationTransition.finished promise fulfilling, when the navigatesuccess event fires.
Either one of these promises rejects if the navigation has failed for some reason.
function initHomeBtn() {
const { key } = navigation.currentEntry;
backToHomeButton.onclick = () => {
navigation.traverseTo(key);
};
}
navigation.addEventListener("navigate", (event) => {
event.intercept({
async handler() {
},
});
});