Reputation: 33
I use this code and it works so that when i reload the page the button is autoclicked but i want to make a delay so that it will be clicked after 60 seconds from page reloading
window.onload = function () {
var button = document.getElementById('clickButton');
button.form.submit();
};
Upvotes: 3
Views: 235
Reputation: 9263
To delay a page to execute some function use setTimeout takes in most cases two arguments the first is the function to be excuted after such a amount of time given by the second argument in ms
setTimeout(
function(){
var button = document.getElementById('clickButton');
button.form.submit();
}
, 60*1000);//60 * 1000 = 60000ms = 60s
Upvotes: 0
Reputation: 1247
window.onload = function() {
setTimeout(() => {
var button = document.getElementById('clickButton');
button.form.submit();
}, 60000);
}
Use setTimeout() https://developer.mozilla.org/en-US/docs/Web/API/setTimeout
Upvotes: 3