When this page finishes loading, the demo displays an alert and then focuses and selects the textbox containing plus2net.
Refresh and try again
Return to Tutorial on Window Load
function myCode() {
alert('Alert inside myCode function');
const textValue = document.getElementById('t2');
textValue.focus();
textValue.select();
}
window.addEventListener('load', myCode);
<form name="form1" method="post" action="">
<label for="t2">Demo textbox</label>
<input type="text" name="t1" value="plus2net" id="t2">
</form>