Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

 Tutorials  References  Exercises  Videos Pro NEW Website NEW Get Certified Log in

Dark mode
Dark code
 HTML CSS JAVASCRIPT SQL PYTHON PHP BOOTSTRAP HOW TO W3.CSS JAVA JQUERY C C++   
DOM Collections ADVERTISEMENT
DOM Node Lists

JS Browser BOM
JS Window
JS Screen
JS Location
Web History API
JS History
❮ Previous Next ❯
JS Navigator
JS Popup Alert
JS Timing
JS Cookies
The Web History API provides easy methods to access the windows.history object.

JS Web APIs The window.history object contains the URLs (Web Sites) visited by the user.
Web API Intro
Web Forms API
Web History API
The Web History API is supported in all browsers:
Web Storage API
Web Worker API
Web Fetch API
Web Geolocation API
Yes Yes Yes Yes Yes

The History back() Method


The back() method loads the previous URL in the windows.history list.
NEW
It is the same as clicking the "back arrow" in your browser.
We just launched
W3Schools videos
Example

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

<script>
function myFunction() {
window.history.back(); Explore now
}
</script>

COLOR PICKER

Go Back

ADVERTISEMENT



Get certified
by completing
a JavaScript
course today!

school
w3 s
2
CE

02

TI 2
R

FI .
ED

The History go() Method


The go() method loads a specific URL from the history list:
Get started

Example CODE GAME


<button onclick="myFunction()">Go Back 2 Pages</button>

<script>
function myFunction() {
window.history.go(-2);
}
</script>

Go Back 2 Pages

Play Game

History Object Properties


Property Description

length Returns the number of URLs in the history list

History Object Methods


Method Description

back() Loads the previous URL in the history list

forward() Loads the next URL in the history list

go() Loads a specific URL from the history list

❮ Previous Next ❯

ADVERTISEMENT

ADVERTISEMENT

Report Error Forum About Buy Certificate

Top Tutorials Top References Top Examples Web Courses


HTML Tutorial HTML Reference HTML Examples HTML Course
CSS Tutorial CSS Reference CSS Examples CSS Course
JavaScript Tutorial JavaScript Reference JavaScript Examples JavaScript Course
How To Tutorial SQL Reference How To Examples Front End Course
SQL Tutorial Python Reference SQL Examples SQL Course
Python Tutorial W3.CSS Reference Python Examples Python Course
W3.CSS Tutorial Bootstrap Reference W3.CSS Examples PHP Course
Bootstrap Tutorial PHP Reference Bootstrap Examples jQuery Course
PHP Tutorial HTML Colors PHP Examples Java Course
Java Tutorial Java Reference Java Examples C++ Course
C++ Tutorial Angular Reference XML Examples C# Course
jQuery Tutorial jQuery Reference jQuery Examples XML Course

Get Certified »

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid
errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

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


W3Schools is Powered by W3.CSS.

You might also like