How to click a browser button with JavaScript automatically?

Solution 1:

setInterval(function () {document.getElementById("myButtonId").click();}, 1000);

Solution 2:

This will give you some control over the clicking, and looks tidy

<script>
var timeOut = 0;
function onClick(but)
{
    //code
    clearTimeout(timeOut);
    timeOut = setTimeout(function (){onClick(but)},1000);
}
</script>
<button onclick="onClick(this)">Start clicking</button>

Solution 3:

document.getElementById('youridhere').click()

Solution 4:

This would work

setInterval(function(){$("#myButtonId").click();}, 1000);

Solution 5:

You can use

setInterval(function(){ 
    document.getElementById("yourbutton").click();
}, 1000);