Description
Event indicates the event status, such as the element that triggers the event object, the location and status of the mouse, and the key to be pressed.
The event object is valid only when an event occurs.
Some Properties of the event only make sense for specific events. For example, the fromElement and toElement attributes only make sense for onmouseover and onmouseout events.
Example
The following example checks whether the mouse is clicked on the link. If the shift key is pressed, the link jump will be canceled.Copy to ClipboardReference: [www.bkjia.com] <HTML>
<HEAD> <TITLE> Cancels Links </TITLE>
<Script language = "JScript">
Function cancelLink (){
If (window. event. srcElement. tagName = "A" & window. event. shiftKey)
Window. event. returnValue = false;
}
</SCRIPT>
<BODY onclick = "cancelLink ()">
The following example shows the current position of the mouse on the status bar.
Copy to ClipboardReference: [www.bkjia.com] <BODY onmousemove = "window. status = 'X = '+ window. event. X + 'y =' + window. event. Y">
Attribute:
AltKey, button, Member, clientX, clientY, ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnValue, screenX, screenY, delimiter, srcElement, srcFilter, toElement, type, x, y
1. altKey
Description:
Check the status of the alt key.
Syntax:
Event. altKey
Possible values:
When the alt key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.
2. button
Description:
Check the pressed mouse key.
Syntax:
Event. button
Possible values:
0 without buttons
1 left click
2. Right-click
3. Press the Left or Right key.
4. Press the intermediate key
5. Press the left and intermediate keys.
6. Right-click and select intermediate key.
7. Press all keys
This attribute is only used for onmousedown, onmouseup, and onmousemove events. For other events, 0 (such as onclick) is returned regardless of the mouse status ).
- Four pages in total:
- Previous Page
- 1
- 2
- 3
- 4
- Next Page