Home >Web Front-end >JS Tutorial >JavaScript implementation method for customizing the right-click menu of any element_Basic knowledge
1. Some concepts:
1. The mouse event has a bottom attribute: it returns an integer to indicate which mouse button was clicked.
BUG: Among the mouse events of IE and standard DOM, the only button attribute value with the same value is the "right-click" event, both of which return 2.
2. Event onmousedown: indicates the action of pressing the mouse button.
Event oncontextmenu: Another event triggered by clicking the mouse.
3. Method to interrupt the default event processing function: set returnValue=false in IE; call preventDefault() method in standard DOM.
4. Event object: ① In IE, the event object is an event attribute of the window object.
Disclaimer:
②In the standard DOM, the event object is the only parameter of the event processing function.
Disclaimer:
Solving compatibility:
2. Implementation:
< ;p id="p1">Uncle Cat is a fat white cat !