Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

window.history

この記事は編集レビューを必要としています。ぜひご協力ください

この翻訳は不完全です。英語から この記事を翻訳 してください。

The Window.history read-only property returns a reference to the History object, which provides an interface for manipulating the browser session history (pages visited in the tab or frame that the current page is loaded in).

See Manipulating the browser history for examples and details. In particular, that article explains security features of the pushState() and replaceState() methods that you should be aware of before using them.

構文

var historyObj = window.history;

history.back();     // equivalent to clicking back button
history.go(-1);     // equivalent to history.back();

注記

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

For security reasons the History object doesn't allow the non-privileged code to access the URLs of other pages in the session history, but it does allow it to navigate the session history.

There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. The closest available solution is the location.replace() method, which replaces the current item of the session history with the provided URL.

仕様

仕様 状態 コメント
WHATWG HTML Living Standard
The History interface の定義
現行の標準
HTML5
The History interface の定義
勧告

ドキュメントのタグと貢献者

 このページの貢献者: momdo, teoli, khalid32, ethertank, Potappo
 最終更新者: momdo,