JavaScript Window History

History Object

The JavaScript History object is used to record the access history of the browser. The History object is part of the window object and can be accessed through the window.history property.

Tip: The effective scope of the History object refers to the current window.

History object length attribute

The History object has a unique length attribute, which is used to get the number of URLs in the browser access history. The example is as follows:

    php中文网(php.cn)  

Explanation

The output result of this example depends on the browsing history of the current page. If the example is opened in a new window, the IE browser will output 0 (That is, counting starts from 0), while browsers such as Firefox and Chrome will output 1.

back() method

back() method is used to return to the previous browsing page (if it exists), its effect is equivalent to clicking to browse the browser's back button or call history.go(-1). The following are commonly used tips for returning to the previous page:

Return to the previous page

   


forward() method

back() method is used to go to the next Navigate to the page (if one exists), which has the effect of clicking the browser's forward button or calling history.go(1). Example:

Go to the next page

   

Note: The back method and the forward method require the browser to have a history record before they can be displayed.


Continuing Learning
||
php中文网(php.cn)
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!