简体   繁体   中英

How to click a browser button with JavaScript automatically?

如何使用JavaScript每秒点击一个按钮?

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

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>
document.getElementById('youridhere').click()

这会奏效

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

You can use

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

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>

`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM