JavaScript combines cookies to achieve browsing history

Source: Internet
Author: User

Recently encountered a problem at work there is a page that needs to add a browsing history feature, specifically to record the user's click history on this site and sort them out in descending order (show only the first 6 browsing histories and not repeat).

Because of the previous understanding of JavaScript is not deep enough, a time of unprepared.

Later, after two master colleagues of the guidance (to the two colleagues of admiration like the surging river endless ... ), suddenly enlightened

The addition of this feature was successfully completed.

Let's start by introducing some of the objects and methods of this feature in javascript:

1. Window.event objects:

An event represents the state of an incident, such as the element that triggers the events object, the position and state of the mouse, the pressed key, and so on.

The event object is valid only if it occurs.

2. Event.srcelement:

Indicates the source of the event the popular point is that where the event is triggered

3. Srcelement.parentnode:

The parent node that represents the source of the occurrence of the event

4. Srcelement.tagname:

Label name that represents the source of the event occurrence

5. toUpperCase ():

How to capitalize the corresponding string

Basically these are the properties and methods that may be unfamiliar to friends who have just been in touch with JavaScript, or friends who used to use them very infrequently, but it doesn't matter, it's not hard to find out later, and the JavaScript validation form isn't much different.

The following on the combination of procedures to give you step-by-step explanation (procedures unavoidably have unreasonable place, I hope everyone will correct, common progress):

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.