<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>focus() 方法</h2> <p>加载文档窗口后,下面的文本字段立即获得焦点。</p> <input type="text" id="myText" value="一个文本字段"> <script> window.onload = function() { document.getElementById("myText").focus(); } </script> </body> </html>