Class: NavigationHistory
Class: NavigationHistory
Manage a list of navigation entries, representing the user's browsing history within the application.
Process: Main
This class is not exported from the 'electron' module. Elle n'est disponible qu'en tant que valeur de retour des autres méthodes dans l'API Electron.
Each NavigationEntry corresponds to a specific visited page. The indexing system follows a sequential order, where the entry for the earliest visited page is at index 0 and the entry for the most recent visited page is at index N.
Some APIs in this class also accept an offset, which is an integer representing the relative
position of an index from the current entry according to the above indexing system (i.e. an offset
value of 1 would represent going forward in history by one page).
Maintaining this ordered list of navigation entries enables seamless navigation both backward and forward through the user's browsing history.
Méthodes d’instance
navigationHistory.canGoBack()
Returns boolean - Whether the browser can go back to previous web page.
navigationHistory.canGoForward()
Returns boolean - Whether the browser can go forward to next web page.
navigationHistory.canGoToOffset(offset)
offsetInteger
Returns boolean - Whether the web page can go to the specified relative offset from the current entry.
navigationHistory.clear()
Efface l'historique de navigation.
navigationHistory.getActiveIndex()
Returns Integer - The index of the current page, from which we would go back/forward or reload.
navigationHistory.getEntryAtIndex(index)
indexInteger
Returns NavigationEntry - Navigation entry at the given index.
If index is out of bounds (greater than history length or less than 0), null will be returned.
navigationHistory.goBack()
Fait revenir le navigateur en arrière d'une page web.
navigationHistory.goForward()
Fait avancer le navigateur d'une page web.
navigationHistory.goToIndex(index)
indexInteger
Fait naviguer le navigateur vers l'index de page web absolu spécifié.
navigationHistory.goToOffset(offset)
offsetInteger
Navigates to the specified relative offset from the current entry.
navigationHistory.length()
Returns Integer - History length.
navigationHistory.removeEntryAtIndex(index)
indexInteger
Removes the navigation entry at the given index. Can't remove entry at the "current active index".
Returns boolean - Whether the navigation entry was removed from the webContents history.
navigationHistory.getAllEntries()
Returns NavigationEntry[] - WebContents complete history.
navigationHistory.restore(options)
Restores navigation history and loads the given entry in the in stack. Will make a best effort
to restore not just the navigation stack but also the state of the individual pages - for instance
including HTML form values or the scroll position. It's recommended to call this API before any
navigation entries are created, so ideally before you call loadURL() or loadFile() on the
webContents object.
This API allows you to create common flows that aim to restore, recreate, or clone other webContents.
Returns Promise<void> - the promise will resolve when the page has finished loading the selected navigation entry
(see did-finish-load), and rejects
if the page fails to load (see
did-fail-load). Un gestionnaire de rejet vide est déjà attaché, ce qui évite les erreurs de rejet non traitées.