i have the following code in timer.php . If i run the file timer.php i get proper output as follows
time left : 02 min 30 sec
and this keeps on decreasing.
But if include the file timper.php in other files using <? require 'timer.php' ?>
only time left :
is shown and actual timer countdown is not shown (in Fire fox). But if i run same thing in ie it is shown correclty.
what is the problem? My timer.php has the flowing code.
<script >
var sec = 00; // set the seconds
var min = 02 // set the minutes
function countDown() {
sec--;
if (sec == -01) {
sec = 59;
min = min - 1;
} else {
min = min;
}
if (sec<=9) { sec = "0" + sec; }
time = (min<=9 ? "0" + min : min) + " min and " + sec + " sec ";
if (document.getElementById) { theTime.innerHTML = time; }
SD=window.setTimeout("countDown();", 1000);
if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); }
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
countDown();
});
</script>
time left :
<span id="theTime" ></span>
Can anyone giv me a code for javascript countdown timer (in minutes) that i can copy pase in my project?