Fires when the object receives focus.
No return value.
The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
Bubbles No Cancels No To invoke Default action Sets focus to an object.
Note Using the IHTMLElement3::setActive method has no effect on document focus. Using the IHTMLControlElement::focus method on an individual element causes the element to gain focus and become the active element.
When one object loses activation and another object becomes the activeElement, the HTMLStyleElementEvents::onfocus event fires on the object becoming the activeElement only after the HTMLStyleElementEvents::onblur event fires on the object losing activation. Use the focus events to determine when to prepare an object to receive input from the user.
Elements cannot receive focus until the document is finished loading.
For Microsoft Internet Explorer 5.5 and later, focus on a document, and the active element of a document can be managed separately. The synchronous events HTMLElementEvents::onactivate and HTMLElementEvents::ondeactivate provide better control for managing activation changes.
As of Internet Explorer 5, elebrowserments retain focus within the current history when the user returns to a page. To avoid firing the HTMLStyleElementEvents::onfocus event unintentionally for an element when the document loads, invoke the focus method on another element.
As of Internet Explorer 5, you can force elements that do not implicitly receive focus to receive focus by adding them to the document tabbing order using the TABINDEX attribute.