You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>El evento onLoad se ejecuta cuando cargamos una página en el navegador. Uno de los usos más frecuentes es para fijar el foco en algún control de un formulario, para que el operador no tenga que activar con el mouse dicho control.</p>
<p>Este evento está asociado a la etiqueta body. La página completa es:</p>
<hr>
<xmp>
<body onLoad="activarPrimerControl()">
<script>
function activarPrimerControl() {
document.getElementById('nombre').focus();
}
</script>
<form>
Ingrese su nombre:
<input type="text" id="nombre"><br>
Ingrese su edad:
<input type="text" id="edad"><br>
<input type="button" value="Confirmar">
</form>
</body>
</xmp>
<hr>
<p>En la marca body inicializamos el evento onLoad con la llamada a la función activarPrimerControl:</p>
<xmp>
<body onLoad="activarPrimerControl()">
</xmp>
<p>La función da el foco al control text donde se cargará el nombre:</p>