My problem is thesame as the following:
Very simple javascript doesn't work at all
But in my case the answers dont help.
In JS fiddles it does work, but when I copy the source code of the JS fiddle result frame it doesnt work anymore (on my server/ computer).
My code (simplified):
<!DOCTYPE html>
<html>
<head>
<title>Stack Overflow</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<p id="countdown2"></p>
<script>
function countdown(element, minutes, seconds) {
var time = minutes*60 + seconds;
var interval = setInterval(function() {
var el = document.getElementById("countdown2");
if(time == 0) {
el.innerHTML = "countdown's over!";
clearInterval(interval);
return;
}
var minutes = Number.floor( time / 60 );
if (minutes < 10) minutes = "0" + minutes;
var seconds = time % 60;
if (seconds < 10) seconds = "0" + seconds;
var text = minutes + ':' + seconds;
el.innerHTML = text;
time--;
}, 1000);
}
countdown("countdown2", 9, 23);
</script>
</body>
</html>
In this JS fiddle it works though. http://jsfiddle.net/Apnu2/374/
My simplified online page:
http://biefstuk.org/mc/faal.html
I've been working on this for more than an hour now...