Causes the element to receive the focus and executes the code specified by the onfocus event.
Returns S_OK if successful, or an error value otherwise.
This method raises the onfocus event. The effect depends on the object calling the method. When called for child windows (such as those created with the IHTMLWindow2::open method of a window object), IHTMLAreaElement::focus brings the target window to the foreground.
Elements cannot receive focus until the document finishes loading.
Windows Internet Explorer 8 and later. The IHTMLAreaElement::focus method no longer brings child windows (such as those created with the IHTMLWindow2::open method) to the foreground. Child windows now request focus from the user, usually by flashing the title bar. To directly bring the window to the foreground, add script to the child window that calls the IHTMLAreaElement::focus method of its window object.
Internet Explorer 7 and later. For security reasons, child windows will only respond to the focus method when the following conditions are true:
- The child window does not have multiple tabs open.
- The focus method was not triggered by a double-click action.
If any of these conditions are true, the child window ignores the focus event.
As of Microsoft Internet Explorer 5, elements that expose the IHTMLAreaElement::focus method must have the TABINDEX attribute set.