Dynamic HTML Tutorial - About Event Objects (Reprinted)

xiaoxiao2021-03-06  14

About Event objects You need to understand the Event object before you fully master DHTML. Both 4.0 browsers contain an EVENT object. It is generated when the event is created, such as clicking a clickable object, moving the mouse, or focuses on a form element. EVENT object is created and passed to a function of the handling event. The following is a description of the Event object properties, and the ways to process them: describe the Microsoft property Netscape property represents the character type string Type Type represents the string Srcelement Target, the Srcelement Target, the horizontal coordinate X x Code longitudinal coordinate Y y with respect to the abscissa clientX pageX page with respect to the ordinate screenY screenY key code keyCode clientY pageY ordinate with respect to the abscissa screenX screenX page screen relative to the screen which Netscape return code of the key, IE returns true or false altKeyctrlKeyshiftKey modifiers 4.0 Browser Added some new events: OndblClick Mouse Double-click the onkeydown button Press the onkeypress button Press the onkeypress button and then release the onkeyup button is released onMousedown Mouse Press the onmousemove Mouse Mobile OnMouseup Mouse release OnResize window Turn 4.0 browser Added a new method of processing events, although they are different from Netscape and IE. Netscape uses "time capture", IE is "event bubble". Event Processing is required for Netscape processing such as MouseMove or KeyPress, which does not imply pointing a tag or element. You should tell customers to pay attention to these events and tell it what function is used to handle them. The following example describes events that are capturing with the CaptureEvents method of the Window object: WINDOW.CAPTUREEVENTS (Event.Mousemove); Notice how a specific event is pointed to without the ON. You just tell Netscape pay attention to all events that happen in the window and capture them. Then you need to tell Netscape what to do with these captured time. Pay attention to ON again. Window.onmouseMove = HandlerFunction; function handerfunction (youRevent (youRevent.screenx);} This code is an annoying example of a demonstration event process. Every time you move your mouse, a dialog will jump out to tell you its horizontal position. Events in this way pass a pointer to the EVENT object. From here you can get the necessary information. Once you are tired of capturing events, you can release them like this: Window.ReleaseEvents (event.mousemove); so this type of event is no longer captured. IE handles events in different ways, called "event bubble". In this approach, if you have such a structure:

转载请注明原文地址:https://www.9cbs.com/read-46536.html


New Post(0)