<html>
<body>
密码:<input type="password" id="myPsw" autofocus>
<p>单击该按钮可查看密码字段是否在页面加载时自动获得焦点。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myPsw").autofocus;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>