History: back() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
History.back()
メソッドは、ブラウザーにセッション履歴内で 1 つ前のページに戻らせます。
これは history.go(-1)
を呼び出すのと同じ効果があります。 1 つ前のページがない場合、このメソッド呼び出しは何もしません。
このメソッドは非同期です。移動が完了したときを検知したい場合は popstate
イベントのリスナーを追加してください。
構文
js
back()
引数
なし。
返値
なし (undefined
)。
例
以下の短い例では、ページ上のボタンを押すとセッション履歴内の 1 つ前の項目に移動します。
HTML
html
<button id="go-back">Go back!</button>
JavaScript
js
document.getElementById("go-back").addEventListener("click", () => {
history.back();
});
仕様書
Specification |
---|
HTML # dom-history-back-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
back |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.