クラス: NavigationHistory
クラス: NavigationHistory
アプリケーション内のユーザーの閲覧履歴を表すナビゲーション項目のリストを管理します。
Process: Main
_This class is not exported from the 'electron'
module. Electron API の他のメソッドの戻り値としてのみ利用できます。
各ナビゲーションエントリは特定のページに対応します。 添字系はシーケンシャルに配置されています。最初の利用可能なナビゲーションエントリは添字 0 にあり、これは最初にアクセスされたページを表します。最新のナビゲーションエントリは添字 N にあり、これは最後にアクセスされたページを表します。 このナビゲーション項目の順序リストを管理することで、ユーザーの閲覧履歴を通じて前後へのシームレスなナビゲーションができるようになります。
インスタンスメソッド
navigationHistory.canGoBack()
戻り値 boolean
- ブラウザが前のウェブページへ戻れるかどうか。
navigationHistory.canGoForward()
戻り値 boolean
- ブラウザが次のウェブページへ進めるかどうか。
navigationHistory.canGoToOffset(offset)
offset
Integer
戻り値 boolean
- 現在のエントリから指定された offset
ぶんウェブページを移動できるかどうか。
navigationHistory.clear()
ナビゲーション履歴を消去します。
navigationHistory.getActiveIndex()
戻り値 Integer
- 現在のページの添字。これはここから戻る/進むまたは再読み込みで変化します。
navigationHistory.getEntryAtIndex(index)
index
Integer
Returns NavigationEntry - Navigation entry at the given index.
index が範囲外の場合 (履歴の長さより大きいか 0 より小さい場合)、null が返されます。
navigationHistory.goBack()
ブラウザを前のページへ戻させます。
navigationHistory.goForward()
ブラウザを次のページへ進めさせます。
navigationHistory.goToIndex(index)
index
Integer
ブラウザを指定した絶対ウェブページインデックスへナビゲーションします。
navigationHistory.goToOffset(offset)
offset
Integer
現在のエントリから指定したオフセットへナビゲーションします。
navigationHistory.length()
戻り値 Integer
- 履歴の長さ。
navigationHistory.removeEntryAtIndex(index)
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.
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
). 無操作拒否ハンドラーが既にアタッチされているため、未処理の拒否エラーは回避されます。