Javascript Reference
Categories: TEXTAREA

javascript TEXTAREA focus( )

@Aug. 28, 2008, 5:23 a.m.
focus( ) Firefox/Netscape/NN 2 IE 3 Chrome/Safari/DOM 1  



Gives focus from the current TEXTAREA object, at which time the TEXTAREA object's onfocus event fires. Note that the range of elements capable of focus and blur (both the event and method) is limited in all browsers except for more recent versions of IE (see the shared tabindex attribute). Most reliably for backward compatibility, apply the focus( ) method to blatantly focusable elements, such as text input and textarea elements.

To give a text box focus and pre-select all the text in the box, use the sequence of focus( ) and select( ) methods on the element. If this sequence is to occur after windows change (such as after an alert dialog box closes), place the methods in a separate function, and invoke this function through the setTimeout( ) method following the alert( ) method for the dialog. This allows IE/Windows to sequence statement execution correctly.



Returned Value


Powered by Linode.