MDN Web Docs

Syntax

js

back()

Parameters

None.

Return value

None (undefined).

Exceptions

SecurityError DOMException

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 in the session history.

HTML

html

<button id="go-back">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

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗