Wayne Gregori Wayne Gregori - 12 days ago 6
Javascript Question

javascript to click a link every 5 seconds

I need a javascript routine that will click a link every n seconds until interrupted. I did find a routine that clicked a button but I don't know how to point the function to a link rather than a .button.

Thanks,
Wayne

Answer

Assuming you're actually trying to click a link that doesn't navigate to another page (what you asked, I suppose), you would probably use jQuery:

var variableToCancelInterval = setInterval(function(){
  $("a.linkclass").click();
}, 5000);
Comments