JavaScript Reference/Javascript Methods/focus
"focus()" Example
<source lang="javascript">
<html> <body> <script language="JavaScript">
function function1() { document.all.myElement.focus(); } function function2() { alert("onFocus event has been fired"); }
</script> <input id="myElement" type="text" value="" onfocus="function2();"> <input type="button"
value="Give focus to the text input element and fire the event" onclick="function1();">
</body> </html>
</source>
"focus()" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> | | | |
| |<body> || |<button>
| | | | | |<custom>
| | | | | |<dir>| | |document
- | | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <hn> | | |
|| |<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"> | | |<isindex> | | |<label> <legend> |
| |- <listing> | | |<marquee> <menu> | | |<object>
| | |
<plaintext> | | |
| | |