Focus OnLoad | JavaScriptSource

Focus OnLoad

JavaScriptSource Staff Sep 9, 2000
You can easily put the user's cursor inside a text box (calling giving the text box focus) as soon as the page is loaded. This helps ensure that visitors do not 'overlook' an important form item on your site. Only 1 line of code!

The JavaScript Source: Page Details: Focus OnLoad

Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!


Did you use this script?  Do you like this site?  Please link to us!

Leave a Response

1 comment)

Is there a way to get the current form name and field name in the OnLoad statement? I don't have control of the form name because the application sets it to a dirivitive of the session ID in our application. I need to set the focus on an input field in a 'subform' of a larger document.

Bob Wylie Oct 31, 2013