メインコンテンツへ飛ぶ

クラス: NavigationHistory

クラス: NavigationHistory

アプリケーション内のユーザーの閲覧履歴を表すナビゲーション項目のリストを管理します。

Process: Main
_This class is not exported from the 'electron' module. Electron API の他のメソッドの戻り値としてのみ利用できます。

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.

インスタンスメソッド

戻り値 boolean - ブラウザが前のウェブページへ戻れるかどうか。

戻り値 boolean - ブラウザが次のウェブページへ進めるかどうか。

  • offset Integer

Returns boolean - Whether the web page can go to the specified relative offset from the current entry.

ナビゲーション履歴を消去します。

戻り値 Integer - 現在のページの添字。これはここから戻る/進むまたは再読み込みで変化します。

  • index Integer

Returns NavigationEntry - Navigation entry at the given index.

index が範囲外の場合 (履歴の長さより大きいか 0 より小さい場合)、null が返されます。

ブラウザを前のページへ戻させます。

ブラウザを次のページへ進めさせます。

  • index Integer

ブラウザを指定した絶対ウェブページインデックスへナビゲーションします。

  • offset Integer

Navigates to the specified relative offset from the current entry.

戻り値 Integer - 履歴の長さ。

  • index Integer

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.

Returns NavigationEntry[] - WebContents complete history.

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.

  • options Object
    • entries NavigationEntry[] - Result of a prior getAllEntries() call
    • index Integer (optional) - Index of the stack that should be loaded. If you set it to 0, the webContents will load the first (oldest) entry. If you leave it undefined, Electron will automatically load the last (newest) entry.

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). 無操作拒否ハンドラーが既にアタッチされているため、未処理の拒否エラーは回避されます。