Summary of JavaScript history objects

Source: Internet
Author: User

Summary of History objects


The history object records the pages (URLs) that the user has browsed, and enables the browser to move forward and backward with similar navigation capabilities.

Note: starting from the moment the window is opened, each browser window, every tab, and even each frame has its own history object associated with a particular window object.

Grammar:

Window.history. [Properties | method]

Note:window can be omitted.

History Object Properties

650) this.width=650; "height=" PNs "style=" Border:0px;width:459px;height:93px;clear:both; "src="/HTTP/ Img.mukewang.com/53548c030001759e05840068.jpg "/>

History Object method

650) this.width=650; "height=" "style=" Border:0px;width:428px;height:117px;clear:both; "src="/HTTP/ Img.mukewang.com/53548c200001228206210123.jpg "/>

Using the Length property, the total length of the current window's browsing history, the code is as follows:

<script type= "Text/javascript" >
var HL = window.history.length;
document.write (HL);
</script>




Return to previous browsed page
Back () method to load the previous URL in the History list.
Grammar:
Window.history.back ();
For example, to return to the previous page of the browse, the code is as follows:
Window.history.back ();
Note: The reverse button is equivalent to clicking the browser.
Back () equivalent to go (-1), the code is as follows:
Window.history.go (-1);


Return to the next browsed page
Forward () method to load the next URL in the history list.
If you want to go back to the page you browsed before going backwards, you can use the forward () method, which is the following code:
Window.history.forward ();
Note: Equivalent click forward button.
Forward () equivalent to go (1), the code is as follows:
Window.history.go (1);


Back to other pages in browsing history
The Go () method loads a specific page in the History list, depending on the page currently in place.
Grammar:
Window.history.go (number);
Parameters:

In the browser, the second history page that was browsed before the current page is returned, with the following code:
Window.history.go (-2);
Note: As in the browser, click the two-time back button operation.
In the same vein, return to the third history page that you visited after the current page, with the following code:
Window.history.go (3);


Summary of JavaScript history objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.