input focus
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

input focus

From: <linuxnooby@yahoo.com.au>
Date: Tue Feb 28 2006 - 23:26:32 CET

This is a simple question but it is doing my head in

all i want is a form text field to be focused when the page loads.
Works in IE6 but not in Firefox 1.6

<body >
<form action="testfocus.htm" method="post" name="test" id="test" >
<input type="text" name="name" id="name"
onLoad="this.forms[0].elements[0].focus()">
<input type="submit" name="submit">
</form>
</body>

I tried variations like

onLoad="this.forms["test"].elements["name"].focus()"
onLoad="this.getByElementId["name"].focus()"
onLoad="this.test.name.focus()"

these all work in IE but not Firefox!!! I need to have the onload event
in the form tag because the body tag is part of an include that is
common to other pages.

help!!!!!!!!!!!!!!!!!!!!!!!!!!
dave
Received on Mon May 1 03:41:48 2006