Default Cursor Position

When the page loads I would like the cursor to be in the first textbox on the page by default (eliminating the need for the user to use the mouse and click on the textbox)
Is there a way to do this in JavaScript? As my application uses a barcode scanner and it would make things much easier when scanning large numbers of the product!

Thanks in advance!


Is that all i need to put in the script?
Sorry ive hardly used javascript before :confused:
The textbox is called “barcode”

<p>Barcode:<input type=“text” name=“barcode” size=“40” /></p>

So would I put something like this:

// –>


give your input an id => <input type=“text” id=“bc1” name=“barcode” size=“40” />

then in js you write: document.getElementById(“bc1”).focus();