I have a html form and want to set focus on a textarea. It work in all browser except opera. Anyone got some workaround?
Works for me in Opera 8.51 for Mac <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Tom Khoury (twaks@yahoo.com) --> <!-- Begin function placeFocus() { if (document.forms.length > 0) { var field = document.forms[0]; for (i = 0; i < field.length; i++) { if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) { document.forms[0].elements[i].focus(); break; } } } } // End --> </script> </HEAD> <!-- STEP TWO: Insert the onLoad event handler into your BODY tag --> <BODY OnLoad="placeFocus()"> <!-- STEP THREE: Copy this code into the BODY of your HTML document --> <form> <input type=text size=10> </form> Code (markup):
thx for the help, but it doesn't work. It highlight the textarea but the cursor is not inside.... i am using a PDA with bar code scanner. The php page should automatically go to the textarea so i don't need to tap the screen at all