Loading Please Wait...

Logo Lynxsia IT Solutions

JavaScript History API

JS Web History API

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.

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
History Object Properties
Property Description
length Returns the number of URLs in the history list
The History back() Method

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="history.back();">Go Back</button>
        
      
The History forward() Method

The forward() method loads the next URL in the windows.history list.

It is the same as clicking the "forward arrow" in your browser.

					 
        
          <button onclick="history.forward();">Go Forward</button>
        
      
The History go() Method

The go() method loads a specific URL from the history list.

					 
        
          <button onclick="history.go(-2);">Go Back 2 Pages</button>
        
      
The History length Property

The length property returns the number of URLs in the history list of the current browser window.

The property returns at least 1, because the list includes the current page.

This property is useful to find out how many pages the user has visited in the current browsing session.

					 
        
          alert(history.length);
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved