Na een paar uur klooien met tutorials, online javascript gidsen, helpfiles geef ik het op en vraag het gewoon.
Ik heb een countdown scriptje, alleen kan ik het niet gebruiken. (lees: ik snap niet wat ik fout doe)
klokbestand.js
De testpagina (die ik open in Firefox 1.0.x en IE6.x om te bekijken):
test.htm
Alé ja, ik denk dat ik daar ergens al fataal de mist in ga. Nooit verschijnt er wat op de pagina, en mja, met de syntax van de js file of de HTML code is niets mis mee :-/ aleen niet erg functioneel natuurlijk
edit: enkel met innerHTML en niet met firstchild.nodevalue, wil het werken. anders toont hij niets en zegt hij dat er voor firstchild.nodevalue geen properties zijn ingesteld. Nu, ok, het werkt. Maar is er dan nog een syntax fout dat hij de getallen verkeerd behandelt? Ik krijg enkel te zien dat ik nog 36xxx dagen moet wachten tot kerst 2005. Of toont hij het bij jullie correct?
Ik heb een countdown scriptje, alleen kan ik het niet gebruiken. (lees: ik snap niet wat ik fout doe)
klokbestand.js
code:
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
58
59
60
61
| function countdown_clock(year, month, day, hour, minute, format)
{
//I chose a div as the container for the timer, but
//it can be an input tag inside a form, or anything
//who's displayed content can be changed through
//client-side scripting.
html_code = '<div id="countdown"></div>';
document.write(html_code);
countdown(year, month, day, hour, minute, format);
}
function countdown(year, month, day, hour, minute, format)
{
Today = new Date();
Todays_Year = Today.getYear() - 2000;
Todays_Month = Today.getMonth() + 1;
//Convert both today's date and the target date into miliseconds.
Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();
//Find their difference, and convert that into seconds.
Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
if(Time_Left < 0)
Time_Left = 0;
switch(format)
{
case 0:
//The simplest way to display the time left.
document.getElementById('countdown').innerHTML = Time_Left + ' seconds';
break;
case 1:
//More datailed.
days = Math.floor(Time_Left / (60 * 60 * 24));
Time_Left %= (60 * 60 * 24);
hours = Math.floor(Time_Left / (60 * 60));
Time_Left %= (60 * 60);
minutes = Math.floor(Time_Left / 60);
Time_Left %= 60;
seconds = Time_Left;
dps = 's'; hps = 's'; mps = 's'; sps = 's';
if(days == 1) dps ='';
if(hours == 1) hps ='';
if(minutes == 1) mps ='';
if(seconds == 1) sps ='';
document.getElementById('countdown').innerHTML = days + ' day' + dps + ' ';
document.getElementById('countdown').innerHTML += hours + ' hour' + hps + ' ';
document.getElementById('countdown').innerHTML += minutes + ' minute' + mps + ' and ';
document.getElementById('countdown').innerHTML += seconds + ' second' + sps;
break;
default:
document.getElementById('countdown').innerHTML = Time_Left + ' seconds';
}
} |
De testpagina (die ik open in Firefox 1.0.x en IE6.x om te bekijken):
test.htm
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="klok.js"></script>
<script type="text/javascript">
function init()
{
countdown(2005,9,4,22,10,1);
}
window.onload=init;
</script>
</head>
<body>
<div id="countdown"></div>
</body>
</html> |
Alé ja, ik denk dat ik daar ergens al fataal de mist in ga. Nooit verschijnt er wat op de pagina, en mja, met de syntax van de js file of de HTML code is niets mis mee :-/ aleen niet erg functioneel natuurlijk
edit: enkel met innerHTML en niet met firstchild.nodevalue, wil het werken. anders toont hij niets en zegt hij dat er voor firstchild.nodevalue geen properties zijn ingesteld. Nu, ok, het werkt. Maar is er dan nog een syntax fout dat hij de getallen verkeerd behandelt? Ik krijg enkel te zien dat ik nog 36xxx dagen moet wachten tot kerst 2005. Of toont hij het bij jullie correct?
[ Voor 135% gewijzigd door Mizitras op 05-09-2005 12:29 ]
"the fucking alpha cpp compiler seems to fuck up the goddam type "LPITEMIDLIST", so to work around the fucking peice of shit compiler we pass the last param as an void *instead of a LPITEMIDLIST"