X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

History back() Method

History Object Reference History Object

Example

Create a back button on a page:

<button onclick="goBack()">Go Back</button>

<script>
function goBack() {
    window.history.back()
}
</script>

The output of the code above will be:


Try it yourself »


Definition and Usage

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

This is the same as clicking the "Back button" in your browser, or history.go(-1).

Note: This method will not work if the previous page does not exist in the history list.

Tip: To load the next URL in the history list, use the history.forward() method.


Browser Support

Method
back() Yes Yes Yes Yes Yes


Syntax

history.back()

Parameters

None

Technical Details

Return Value: No return value


History Object Reference History Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook