Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/03/2009, 15:24
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Añadir foco a un input txt

Es posible que tengas otro onload que sobreescriba el que estás mostrando (quizá un body onload), porque así sí funciona:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<script type="text/javascript">
    onload = focusIt;
    function focusIt()
    {
      document.frmContacta.txtNombre.focus();
    }
</script>
</head>

<body>

 <form name="frmContacta" action="contacta.php" method="POST">
          <label>Nombre: </label><input type="text" name="txtNombre" value="" size="30">
          <label>Correo electrónico: &nbsp;</label><input type="text" name="txtCorreo" value="" size="30"><br><br>
          <label>Asunto: &nbsp;</label><input type="text" name="txtAsunto" value="" size="50"/><br><br>
          <label>Mensaje: </label><textarea name="txtMensaje" rows="4" cols="45">
          </textarea><br>
          <input type="submit" class="boton" value="Enviar" name="cmdEnviar"/>
</form>
</body>
</html>