focus method

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

Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5

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

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
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=email
input type=file
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
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

 

 

Show:
© 2014 Microsoft