blog.autopsy.se

basically; it sucks. everything sucks. but.. in a good way..

javascript and timers sucks!

Have been trying to get my head around timers in javascript. And I guess i know how it works now. My approach:

<script>
var timer;
function whatever() {
if ( timer )
clearTimeout(timer);
alert("you just wasted 15 seconds of your life..");
timer = startTimeout('whatever()', 15000);
}
</script>

and in the html:

<body onLoad="timer = startTimeout('whatever()', 15000);"> yada yada..

this will generate an annoying popup (if I made the example correct..) every 15 seconds..

Why I need this? Well, on tv.autopsy.se I want to update the search cloud continuously without having to do some reloads. And I also have a timer that waits 4s to insert data into the database for the search cloud. Neat, huh?

posted by ube in Javascript and have No Comments

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment