Site icon i2tutorials

Javascript Browser History

Javascript Browser History

 

The javascript window.history object contains the history of the browser. First of all, the javascript window part can be removed from the window.history just using(provided) the history object alone works fine. The JS(javascript) history object contains an array of URLs (browser) visited by the user. By using the history object, you can load previous, forward, or any particular page using various methods.

 

Property of JavaScript history object :

 

 

Methods of JavaScript history object :

 

 

Example:

 

<html>
<head>
<title>back() example</title>
</head>
<body>
<b>Press the back button</b>
<input type="button" value="Back" onclick="previousPage()">
<script>
function previousPage() {
       window.history.back();
}
</script>
</body>
</html>

 

OUTPUT:

 

Press the back button Back

 

 

Exit mobile version