Causes the element to receive the focus and executes the code specified by the onfocus event.
![]() |
Syntax
object.focus()Parameters
This method has no parameters.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
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.
Elements cannot receive focus until the document finishes loading.
See also
- a
- abbr
- address
- area
- b
- bdo
- blockQuote
- body
- button
- caption
- cite
- custom
- dd
- del
- dl
- document
- dt
- em
- embed
- fieldSet
- form
- 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
- kbd
- label
- legend
- li
- object
- ol
- p
- pre
- q
- rt
- ruby
- s
- samp
- select
- small
- span
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- u
- ul
- var
- window
Build date: 11/28/2012
