Created
May 24, 2010 17:27
-
-
Save peteonrails/412151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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