DHTML object model (3)

zhaozj2021-02-16  79

Prohibition of incident:

All events will bubbber to their parent elements, and unless the event is prohibited during the bubbling process, the event will be recursively along the path of the Document Object (Document Object). To prohibit an event, you must set the value of the Window.Event.cancelbble property to "True" in the event handle. Note that unless the event is banned, otherwise, in the process of bubbling along the hierarchy, it will be processed by all the parent elements of this event handle, even if it has been processed in child elements. .

The default behavior for prohibiting event bubbling and prohibiting events is different. Some events (for example: OnClick on an anchor) have default behavior. When an anchor is clicked, its default behavior is to navigate the current window to the URL specified by its SRC property. Returns "false" in the event handle, or set the Window.Event.ReturnValue property to "false", and the default behavior of the event can be disabled, but the incident is not prohibited from bubbling. It is forbidden to bubbling up, and only the Window.Event.ReturnValue property is set to "True", which corresponds to the pre-emptive settings, and will prohibit the default behavior of the event.

The last example is to demonstrate how to use event bubbling to apply a common effect to a set of elements. If you want to exclude one of the elements in this effect, just simply put the following line of code, from:

HAM modified to:

">"> "> HAM is OK.

(Example Super Link:

http://msdn.microsoft.com/workshop/samples/author/dhtml/overview/Dom_03.htm)

Further think: In some cases, you can let an onmouseover event only register on an object, consider the following situation:

If you move your mouse pointer on an IMG object, the event will be excited in the following order:

Mydiv :: OnMouseOvermydiv :: OnMouseoutmyimg :: OnMouseOver removes your mouse pointer from the IMG object to the MYDIV :: ONMOUSEOVER event again.

Sometimes, web producers may want to detect when the mouse pointer moves out of a DIV object to achieve some kind.

Special effect. At this time, it is not enough to simply set the onmouseout event. In order to make this situation easier, IE4.0 standard adds to the ONMOUSEOVER and the ONMOUSEOUT event to indicate the properties of the source object (TOEELEMENT), you can integrate these properties and containers to identify the mouse pointer? A area is removed.

The following example demonstrates how to use these properties and methods:

(Example Super Link:

http://msdn.microsoft.com/workshop/sample/author/dhtml/overview/Dom_04.htm)

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

New Post(0)