How to click a browser button with JavaScript automatically?

JavascriptButtonEvent Handling

Javascript Problem Overview


How to click a button every second using JavaScript?

Javascript Solutions


Solution 1 - Javascript

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

Solution 2 - Javascript

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 - Javascript

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

Solution 4 - Javascript

This would work

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

Solution 5 - Javascript

You can use

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

Solution 6 - Javascript

this will work ,simple and easy

 `<form method="POST">
<input  type="submit" onclick="myFunction()" class="save" value="send" name="send" id="send" style="width:20%;">
</form>
<script language ="javascript" >
function myFunction() {
setInterval(function() {document.getElementById("send").click();}, 10000);    
}
</script>

`

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Question001View Question on Stackoverflow
Solution 1 - JavascriptJohn HartsockView Answer on Stackoverflow
Solution 2 - JavascriptIsaacView Answer on Stackoverflow
Solution 3 - JavascriptKonaRinView Answer on Stackoverflow
Solution 4 - JavascriptMeuruView Answer on Stackoverflow
Solution 5 - JavascriptFooterView Answer on Stackoverflow
Solution 6 - JavascriptnikunjView Answer on Stackoverflow