- <html>
- <head>
- <title>设置焦点</title>
- <script language ="javascript">
- function init(){
- var ctrl=document.getElementById("UserName");
- ctrl.focus();
- }
- </script>
- </head>
- <body onload="init()" >
- <h1>设置焦点</h1>
- 姓名:<input type="text" id="UserName">
- </body>
- </html>