Window history.back()

Example

Create a back button on a page:

<button onclick="history.back()">Go Back</button>

The output of the code above will be:

Click on Go Back to see how it works.
(Will only work if a previous page exists in your history list)

Try it Yourself »

Description

The history.back() method loads the previous URL (page) in the history list.

The history.back() method only works if a previous page exists.

Note

history.back() is the same as history.go(-1).

history.back() is the same as clicking "Back" your browser.

See Also:

The history.forward() Method

The history.go() Method

The history.length Property


Syntax

history.back()

Parameters

NONE

Return Value

NONE

Browser Support

history.back() is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.