<!DOCTYPE html>
<html>
<body>

<button id="myBtn" autofocus>My Button</button>

<p>Click the button below to find out if the button above automatically gets focus when the page loads.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myBtn").autofocus;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>