aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/window/history/index.html
blob: e7a7e8ebc71315db475091b1922551b4e99f451d (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
---
title: window.history
slug: Web/API/Window/history
tags:
  - Gecko
  - HTML DOM
  - History API
  - Window
  - 要更新
translation_of: Web/API/Window/history
---
<p>{{ ApiRef }}</p>

<p>読み取り専用プロパティ<code><strong>Window</strong>.<strong>history</strong></code>は、{{domxref("History")}}オブジェクトへの参照を返します。{{domxref("History")}}はブラウザのセッション(今開いているタブやそのページが読み込まれているウィンドウで過去に訪れたページの履歴)を操作するインターフェースを提供します。</p>

<p>詳細や使用例については <a href="/en/DOM/Manipulating_the_browser_history" title="en/DOM/Manipulating the browser history">Manipulating the browser history </a>をご覧ください。このページでは特に<code>pushState()</code>メソッドや <code>replaceState()</code>メソッドについてセキュリティの観点から詳しく解説がなされています。これらのメソッドは注意して使う必要があります。</p>

<p>{{ 英語版章題("Syntax") }}</p>

<h3 id="構文">構文</h3>

<pre class="syntaxbox"><em>var historyObj</em> = <em>window</em>.history;
</pre>

<p>{{ 英語版章題("Example") }}</p>

<h3 id="例"></h3>

<pre class="brush: js">history.back();     // 戻るボタンを押したのと同じ効果
history.go(-1);     // history.back();と同等の効果が得られます
</pre>

<p>{{ 英語版章題("Notes") }}</p>

<h3 id="注記">注記</h3>

<p>For top-level pages you can see the list of pages in the session history, accessible via the <code>History</code> object, in the browser's dropdowns next to the back and forward buttons.</p>

<p><code>History</code>オブジェクトはセッション履歴の他のページのURLへアクセスしようとする許可なきコードはセキュリティ上の理由から禁止しています。ただ、セッション履歴のあいだを行き来することは許可されています。</p>

<p>権限のないコードでセッション履歴を消去したり、戻る/進む操作を無効にしたりする方法はありません。このような機能をどうしても実現したいのなら<code><a href="/ja/DOM/window.location#replace">location.replace()</a></code> メソッドを使うのがよいでしょう。このメソッドは現在のセッションを引数のURLに置き換えることができます。</p>

<p>{{ 英語版章題("Specification") }}</p>

<h3 id="仕様">仕様</h3>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">仕様</th>
   <th scope="col">状態</th>
   <th scope="col">コメント</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'browsers.html#the-history-interface', 'The History interface')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'browsers.html#the-history-interface', 'The History interface')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>