Javascript countdown klokje
Ik heb een javascript countdown klokje van internet maar deze geeft om de een of andere reden geen output.
Weet iemand wat hier mis mee is:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<script type="text/javascript">
var nIndex = '<?php echo "$time_difference"; ?>'; // 35 days, in seconds;
var GMToffset = 2; // your current GMT offset;
var refDate = new Date(); // start date;
refDate = new Date(refDate.getFullYear(),
refDate.getMonth(),
refDate.getDate(),
refDate.getHours(),
refDate.getMinutes(),
refDate.getSeconds()+nIndex,
0);
var done = false;
function init(){
var currDate = new Date();
currDate.setHours(GMToffset+currDate.getHours()+currDate.getTimezoneOffset()/60);
if (refDate < currDate)
{
document.getElementById('display').innerHTML = "Ready for Upgrade.";
done = true;
}
var remTime = refDate-currDate;
var nDays = parseInt(remTime/86400000);
var nHours = parseInt((remTime-(nDays*86400000))/3600000);
var nMin = parseInt((remTime-(nDays*86400000)-(nHours*3600000))/60000);
var nSec = 0;
if (refDate > currDate)
{
nSec = 60-(currDate.getSeconds());
}
else {
nSec = currDate.getSeconds();
}
var nMonths = parseInt(nDays/30);
var rDays = parseInt(nDays-(nMonths*30));
if (!done)
{
setTimeout("init()", 1000);
document.getElementById('display').innerHTML = nMonths + " Months, " + rDays +
" Days, " + nHours + " Hours, " + nMin + " Minutes, " + nSec + " Seconds";
}
}
navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);
</script>
<style type="text/css">
body {margin-top: 0px;}
.timer_countdown {width: 460px; margin-left: auto; margin-right: auto;
margin-top: 0px; text-align: center; font-family: 'times new roman';
font-size: 12pt; color: #FFFFFF; background-color: #002b4d;
padding-bottom: 3px;}
</style>
var nIndex = '<?php echo "$time_difference"; ?>'; // 35 days, in seconds;
var GMToffset = 2; // your current GMT offset;
var refDate = new Date(); // start date;
refDate = new Date(refDate.getFullYear(),
refDate.getMonth(),
refDate.getDate(),
refDate.getHours(),
refDate.getMinutes(),
refDate.getSeconds()+nIndex,
0);
var done = false;
function init(){
var currDate = new Date();
currDate.setHours(GMToffset+currDate.getHours()+currDate.getTimezoneOffset()/60);
if (refDate < currDate)
{
document.getElementById('display').innerHTML = "Ready for Upgrade.";
done = true;
}
var remTime = refDate-currDate;
var nDays = parseInt(remTime/86400000);
var nHours = parseInt((remTime-(nDays*86400000))/3600000);
var nMin = parseInt((remTime-(nDays*86400000)-(nHours*3600000))/60000);
var nSec = 0;
if (refDate > currDate)
{
nSec = 60-(currDate.getSeconds());
}
else {
nSec = currDate.getSeconds();
}
var nMonths = parseInt(nDays/30);
var rDays = parseInt(nDays-(nMonths*30));
if (!done)
{
setTimeout("init()", 1000);
document.getElementById('display').innerHTML = nMonths + " Months, " + rDays +
" Days, " + nHours + " Hours, " + nMin + " Minutes, " + nSec + " Seconds";
}
}
navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);
</script>
<style type="text/css">
body {margin-top: 0px;}
.timer_countdown {width: 460px; margin-left: auto; margin-right: auto;
margin-top: 0px; text-align: center; font-family: 'times new roman';
font-size: 12pt; color: #FFFFFF; background-color: #002b4d;
padding-bottom: 3px;}
</style>
Thnx Ryflex
Graag in het vervolg bij code, [code] [/code] tags gebruiken. [/modedit]
Gewijzigd op 07/10/2010 17:19:51 door Bas IJzelendoorn
Roep je init() aan? En heb je een element met het id display?
dit is hoe ik het script aanroep
Thnx Ryflex