focus on first text form field w/o using onload

R

reneecccwest

hello, is there any way to indicte a cursor on the first text user
input when a page loads without using onload in the body tag?
 
M

McKirahan

reneecccwest said:
hello, is there any way to indicte a cursor on the first text user
input when a page loads without using onload in the body tag?


<html>
<head>
<title>focus.htm</title>
</head>
<body>
<form>
<input type="text" name="field1">
<input type="text" name="field2">
</form>
<script type="text/javascript">
document.forms[0].field1.focus();
</script>
</body>
</html>


Though, <body onload="document.forms[0].field1.focus()"> would be simpler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top