Reputation: 244
I have a website with a Javascript button, that submits the code entered and refreshes the screen. This is on a open source application and it not my own code.
This button does the job most of the time, but I would like to "hook" into this feature if that is the correct terminology and auto refresh the submit at a specific interval.
<button id="dataRefreshButton" type="submit" title="Refresh with latest data." class="button capsule up">
I was wondering if there is a way to auto submit this code in some way?
Upvotes: 0
Views: 7391
Reputation: 802
See http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml for info on form submission.
As for specific intervals use either
setInterval(function() {/*you code*/}, time_interval);
or
function tick() {
setTimeout(function() {tick(); /*you code*/}, time_interval);
};
with the submission along the lines of:
document.forms["myform"].submit();
Upvotes: 0
Reputation: 39704
something like setTimeout()
and click()
:
<script type="text/javascript">
setTimeout(function(){ document.getElementById('dataRefreshButton').click(); }, 5000); // 5 seconds
</script>
or setInterval()
:
<script type="text/javascript">
setInterval(function(){ document.getElementById('dataRefreshButton').click(); }, 5000); // every 5 seconds
</script>
Upvotes: 3