Web History API

JS Tutorial

JS Version

JS Objects

JS Function

JS Classes

JS Async

JS HTML DOM

JS Browser BOM

JS Web API

JS AJAX

JS JSON

JS vs JQUERY

JS Graphics

Web History API

The History back() Method

The back() method is used to load the previous URL in the windows.history list.

It is the similar as clicking the “back arrow” in your browser.

Example

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

<script>

function myFunction() {

  window.history.back();

}

</script>

The History go() Method

The go() method is used to load a definite URL from the history list:

Example

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

<script>

function myFunction() {

  window.history.go(-2);

}

</script>

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
 

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420