jQuery History Example
jQuery History Example

The goal of this example is to show you how to use illustration he jQuery for allowing the browser history. Sometimes the web site’s user can need to go back to the previous page or forward to the next page.

The following methods can be used for this purpose.

  1. back() a method for loading the previous URL in the history list.
  2. forward() method for loading the next URL in the history list.

Let’s look at some examples. To download the jQuery library, click here.

jQuery History Examples

Handle by using,back() forward() methods

Let’s add the following easy HTML code to the jQueryHistoryExample1 page.

The forward() method had been adoption to access next page.

And add the following code to the jQueryHistoryExample1page.

As you can notice, to get the previous page we want to use back() the method.

The result in the browser would be:

history
history

Go to the previous page

Let’s add the following easy HTML code to the jQueryHistoryExample2 page.

And add the following code to the jQueryHistoryExample2 page.

As you can notice, to get the preceding page we need to use back() a method.

The result in the browser would be:

jquery
jquery

HTML

First of all, you want to create two easy HTML documents.

Check History Length

Let’s add the following simple HTML code to the jQueryHistoryExample1 page.

We can approach the browser session history object length by using: history.length , it will arrival the number of browsing session history. It will return 1 even though we have nowhere to go to. Using this find out will helps as to make composed navigation
The result in the browser would be.
jQueryHistory
jQueryHistory
See more: