I must admit that I've only been following this thread in a general sort of way - with reason. In cases like this, fundamental concepts are sometimes more important than the actual code, which I'm fairly confident you can work up to your satisfaction once you get the idea. But I'll work with you until you get something that works for you.
You should study the Date object, it will prove enlightening. However it has numerous properties, not all of which are applicable to your code.
From what I can tell by skimming this thread, you want to create a reliable timer or reliable timers.
Let's start simple. Say you want to show an alert 20 seconds from now:
Code:
<script type="text/javascript">
function timer_1(){
var later = new Date();
later.setSeconds(later.getSeconds() + 20);
var getIt = function(){
var now = new Date().valueOf();
if (now >= later.valueOf()){
clearInterval(getIt.inv);
alert('times up');
}
};
getIt.inv = setInterval(getIt, 100);
};
timer_1();
</script>
Bookmarks