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):