<html>
<body>
<input type="file" id="myFile" autofocus>
<p>单击“尝试”按钮可查看文件上传按钮是否在页面加载时自动获得焦点。</p>
<p id="demo"></p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
var x = document.getElementById("myFile").autofocus;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>