Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Methods
 focus Method
focus Method

Causes the element to receive the focus and executes the code specified by the onfocus event.

Syntax

object.focus()

Return Value

No return value.

Remarks

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 open method of a window object), focus brings the target window to the foreground.

Windows Internet Explorer 8 and later. The focus method no longer brings child windows (such as those created with the 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 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 focus method must have the TABINDEX attribute set.

Elements cannot receive focus until the document finishes loading.

Standards Information

This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To

A, ABBR, ACRONYM, ADDRESS, APPLET, AREA, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CUSTOM, DD, DEL, DFN, DIR, DL, document, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OBJECT, OL, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, window, XMP, Element Constructor, HTMLDocument Constructor, Window Constructor
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
input type=text / zIndex bug      george_5154   |   Edit   |   Show History
If you transfer the focus to an input control and then you stack another element on the top of the input control, the caret apears as if it belonged to the second element and not to the input control, even if the second element has a higher zIndex. In an old fashioned web aplication you want the space used by the input control to be clear all the time, however moden needs requiere windowing systems that eventualy and unavoidably will place something above an input control. Every time I'm more and more disapointed of Microsoft because it seems like everyone else was able to forseen this kind of scenarios long time ago and Microsoft hasn't.
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker