## Focus

What is focus? Focus is when something is active or highlighted. Example: When the cursor is in a form blinking. That form has the focus. The following are examples of how to use the focus command.

### Focus to a text box when page loads.

See how the cursor is already in the form. Normally the cursor won't be in it. Put the following lines into your body tag.

    <body onLoad="this.document.form1.a.focus();">

An example is:
`<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#000080" ALINK="#000080" onLoad="this.document.form1.a.focus();">`
or
`<body onLoad="this.document.form1.a.focus();">`
And put this somewhere in your page.

    <form name=form1>
    <input type="text" size=40 name="a" value="">
    <input type="text" size=40 name="b" value="http://"></form>

### Giving focus to a form and to having all the words inside it highlighted

Just copy the following lines.

    <body onLoad="this.document.form1.a.focus(); this.document.form1.a.select();">
    <form name=form1>
    <input type="text" size="100" name="a" value="">
    <input type="text" size="100" name="b" value="http://"></form>

### Highlighting a text area

Next Step Software brings us the best Java Scripts possible. Total Java Scripts is the bomb for Java Stuff!! Yeah Right!!!!!!!1

Now all you need to do is goto Edit and hit copy and BAM! You just copied that script!! To use this copy this code.

    <form name=form2>
    <textarea name="c" rows=4 cols=40>
    <script>
    document.write("Hello there!!!")
    </script>
    </TEXTAREA><br>
    <input type="button" value="Select" onClick="document.form2.c.focus(); document.form2.c.select();">
    </form>

You can use this for regular text boxes as well!

### Giving the focus to a button

See how the text in the button has a box around it. If you hit the space bar, you can press in the button. A more practical use for this is using the onLoad function. Here is the script.

    <body onLoad="this.document.form3.d.focus();">
    <form name=form3>
    <input type=button name=d value="DESCRIPTION"></form>

Quick Note: To declare a certain form or button part of you code would look like this:
`< body onLoad="document.form1.a.focus()">`
In the onLoad command, "document" refers to the current document. "form1" refers to the the name of a from. "a" refers to the name of the input type within the form. "focus()" is the focus command ( "select()" selects all the text). This should help you if you want to create your own focus commands.