aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/history/back/index.html
blob: 122d0f7351cc082fa69ea36e418535b00d839db8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: History.back()
slug: Web/API/History/back
tags:
  - API
  - HTML DOM
  - History
  - History API
  - Method
  - Reference
  - Web
translation_of: Web/API/History/back
---
<div>{{APIRef("History API")}}</div>

<p><span class="seoSummary"><strong><code>History.back()</code></strong> メソッドは、ブラウザーにセッション履歴内で1つ前のページに戻らせます。</span>これは {{domxref("History.go", "history.go(-1)")}} を呼び出すのと同じ効果があります。1つ前のページがない場合、このメソッド呼び出しは何もしません。</p>

<p>このメソッドは{{glossary("asynchronous", "非同期")}}です。移動が完了したときを検知したい場合は {{event("popstate")}} イベントのリスナーを追加してください。</p>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox notranslate">history.back()</pre>

<h2 id="Examples" name="Examples"></h2>

<p>以下の短い例では、ページ上のボタンを押すとセッション履歴内の1つ前の項目に移動します。</p>

<h3 id="HTML">HTML</h3>

<pre class="brush: html notranslate">&lt;button id="go-back"&gt;Go back!&lt;/button&gt;</pre>

<h3 id="JavaScript">JavaScript</h3>

<pre class="brush: js notranslate">document.getElementById('go-back').addEventListener('click', () =&gt; {
  history.back();
});</pre>

<h2 id="Specifications" name="Specifications">仕様書</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">仕様書</th>
   <th scope="col">状態</th>
   <th scope="col">備考</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("HTML WHATWG", "history.html#history", "History.back()")}}</td>
   <td>{{Spec2("HTML WHATWG")}}</td>
   <td>{{SpecName("HTML5 W3C")}} から変更なし</td>
  </tr>
  <tr>
   <td>{{SpecName("HTML5 W3C", "browsers.html#dom-history-back", "History.back()")}}</td>
   <td>{{Spec2("HTML5 W3C")}}</td>
   <td>初回定義</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>

<p>{{Compat("api.History.back")}}</p>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{domxref("History")}}</li>
 <li><a href="/ja/docs/Web/API/History_API/Working_with_the_History_API">History API での作業</a></li>
</ul>