Skip to content

Instantly share code, notes, and snippets.

@peteonrails
Created May 24, 2010 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peteonrails/412151 to your computer and use it in GitHub Desktop.
Save peteonrails/412151 to your computer and use it in GitHub Desktop.
// For Aaron
// You can replace the passed anonymous function with a callback if you'd rather.
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script type='text/javascript'>
new PeriodicalExecuter(function(pe) {
if (!confirm('Want me to annoy you again later?'))
pe.stop();
}, 5);
</script>
// If you're using jQuery instead, use the jQuery Timer Plugin
//
<script src="/javascripts/jquery.js" type="text/javascript"></script>
<script src="/javascripts/jquery.timer.js" type="text/javascript"></script>
<script type='text/javascript'>
$.timer(1000, function (timer) {
alert("hello");
timer.stop();
});
</script>
// Or if you're trying to "roll your own'
// use setTimeout and recursively call yourself.
// Something like this, I think:
<script type='text/javascript'>
function invokeCallback() {
alert('I am unstoppable!!!!');
setTimeout(invokeCallback(), 1000);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment