I feel like this must be very simple, but for some reason I am getting no results from this:
<script>
function sendAlert() {
alert('hello world');
}
var timer = window.setTimeout(sendAlert, 2000);
</script>
Should this not be counting 2000ms and then calling sendAlert()? Have I understood this wrong? I have also tried this outside of a variable (ie. window.setTimeout() not declared as var timer) and had no result either. This seems so easy, what am I doing wrong!?
UPDATE:
I’m an idiot. I had script tags with bad links to javascript documents in the header of my doc, breaking javascript in general on the page. Thanks internet. ;p
OP just updated his post:
Well, that explains it. Always check your error console! 🙂