Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. History
  4. back()

History: back() method

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.

Theback() method of theHistory interface causesthe browser to move back one page in the session history.

It has the sameeffect as callinghistory.go(-1). If there is no previouspage, this method call does nothing.

This method isasynchronous. Add a listener for thepopstate event in order to determine when the navigation has completed.

Syntax

js
back()

Parameters

None.

Return value

None (undefined).

Exceptions

SecurityErrorDOMException

Thrown if the associated document is not fully active. Browsers also throttle navigations and may throw this error, generate a warning, or ignore the call if it's called too frequently.

Examples

The following short example causes a button on the page to navigate back one entry inthe session history.

HTML

html
<button>Go back!</button>

JavaScript

js
document.getElementById("go-back").addEventListener("click", () => {  history.back();});

Specifications

Specification
HTML
# dom-history-back-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp