HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The Web History API provides easy methods to access the windows.history object.The window.history object contains the URLs (Web Sites) visited by the user.
The back() method loads the previous URL in the windows.history list.
It is the same as clicking the "back arrow" in your browser.
<button onclick="myFunction()">Go Back</button>
<script>
function myFunction() {
window.history.back();
}
</script>
function goBack() { window.history.back(); }
The go() method loads a specific URL from the history list:
<button onclick="myFunction()">Go Back 2 Pages</button>
<script>
function myFunction() {
window.history.go(-2);
}
</script>
function goBack() { window.history.go(-2); }
Property | Description |
---|---|
length | Returns the number of URLs in the history list |