Navigation: reload() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The reload() method of the
Navigation interface reloads the current URL, updating any provided state in the history entries list.
Syntax
navigate(options)
Parameters
optionsOptional-
An options object containing the following properties:
stateOptional-
Developer-defined information to be stored in the associated
NavigationHistoryEntryonce the navigation is complete, retrievable viagetState(). This can be any data type. You might, for example, wish to store a page visit count for analytics purposes, or store UI state details so the view can be shown exactly as the user last left it. Any data stored instatemust be structured-cloneable. infoOptional-
Developer-defined information to be passed along to the
navigateevent, made available inNavigateEvent.info. This can be any data type. You might, for example, wish to display newly-navigated content with a different animation depending on how it was navigated to (swipe left, swipe right, or go home). A string indicating which animation to use could be passed in asinfo.
Return value
An object with the following properties:
committed-
A
Promisewhich will fulfill when the visible URL has changed and a newNavigationHistoryEntryhas been created. finished-
A
Promisewhich will fulfill when all promises returned by theintercept()handler are fulfilled. This is equivalent to theNavigationTransition.finishedpromise fulfilling, when thenavigatesuccessevent fires.
Either one of these promises rejects if the navigation has failed for some reason.
Exceptions
DataCloneErrorDOMException-
Thrown if the
stateparameter had values included in it that are not structured-cloneable.
Examples
Using info and state
async function handleReload() {
await navigation.reload({
info: { animation: "fade-in" },
state: { infoPaneOpen: true },
}).finished;
// Update application state
// ...
}
Reload page and add a new state item:
async function handleReload() {
await navigation.reload({
state: { ...navigation.currentEntry.getState(), newState: 3 },
}).finished;
// Update application state
// ...
}
Specifications
| Specification |
|---|
| HTML Standard # dom-navigation-reload-dev |
Browser compatibility
BCD tables only load in the browser