The HTML Attribute reference

"onfocus" - html Event

  • The onfocus event occurs when an element receives focus either by the pointing device or by tabbing navigation.

Value(s): One or more script statements each ended with a semicolon.

Event "onfocus" example:
<html>
  <body>
    <form name="myform" action="http://www.google.com/search">
      <input type="text" name="q" value="w3c"
             onfocus="this.value='w3c';"
             onblur="alert(this.type+' lost focus')"/>
      Focus test:
      <input type="checkbox"
             onfocus="document.myform.q.value=this.type+' in focus';"
             onblur="alert(this.type+' lost focus')"/>
      <button id="mybutton" title="Show on goggle"
               type="submit" value="Search">
        Search google</button>
    </form>
  </body>
</html>
Used in the element(s):
Elements Description
a The A element denotes an anchor; a hypertext link or the destination of a link.
area This element defines a map region on a client-side image.
button This element defines a submit button, reset button, or push button.
input This element defines a form control for the user to enter input.
label This element associates a label with a form control.
select This element defines a form control for the selection of options. It is is most useful within a FORM.
textarea This element is used in forms to get multiple lines of text from the user.

© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.