July 8, 2000 - HTC-Master Focus/Blur Events | WebReference

July 8, 2000 - HTC-Master Focus/Blur Events

Yehuda Shiran July 8, 2000
HTC-Master Focus/Blur Events
Tips: July 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

The focus and blur events are treated as special-case events in the communication model between a primary document and its HTC. The uniqueness stems from the requirement not to fire focus/blur events on the master element whenever a user changes focus between elements in a component. As a result, the focus/blur events are treated in exactly the same way as the mouse events. There are six focus/blur events in their occurrences' sequence: onbeforefocusenter, onfocusenter, onfocus, onbeforefocusleave, onfocusleave, and onblur.

The onfocusenter and onfocusleave events cannot be cancelled. When they fire on the root element of the HTC tree, the onfocus and onblur events, respectively, are fired on the master element in the primary document. The onbeforefocusenter and onbeforefocusleave events do not bubble but can be cancelled. Since they do not bubble, only occurrences of these events directly on the root element of the HTC tree are fired on the master element. But, because these events can be cancelled, focus on the master element can be cancelled.