I have made this timer script but I can’t seem to make it so ti starts onclick.
Here is my whole code:
<script type="text/javascript">
function display( notifier, str ) {
document.getElementById(notifier).innerHTML = str;
}
function toMinuteAndSecond( x ) {
return Math.floor(x/60) + ":" + x%60;
}
function setTimer( remain, actions ) {
(function countdown() {
display("countdown", toMinuteAndSecond(remain));actions[remain] && actions[remain]();
(remain -= 1) >= 0 && setTimeout(arguments.callee, 1000);
})();
}
setTimer(20, {
20: function () {
display("notifier", "seconds");
},
1: function () {
display("notifier", "second");
},
0: function () {
display("notifier", "seconds");
}
}
);
</script>
<!--Start Redirect Countdown-->
<div id="redirect_box" style="display:block;">
Redirecting in <span id="countdown"></span> <span id="notifier"></span>
</div>
<!--End Redirect Countdown-->
<div id="buttonn">Skip >></div>
Skip >> is suppose be the button that starts the timer and the ID, countdown is the actual countdown. And, notifier is just an extra ID.
I hope someone can help
Is this what you’re after? http://jsfiddle.net/JAAulde/Mnqaj/
If so, all you needed to do is grab the
buttonnelement and assign an onclick to it.That’s, ummm, quite a thingy…