Hey
jeg sidder her med noget Javascript som virker i FF men ikke i IE, det den gør er at tælle ned til hvornår en konkurrence slutter:
Der hvor det skal vises:
<script type="text/javascript" src="js/countdown.js"></script>
<script type="text/javascript">
var start = new Date();
function showTime(){
ref();
if(typeof refd != 'object' || !refd.getTime){
refd = new Date(0);
}
var nuTid = refd.age(0,0,6,1);
var newstr = nuTid.replace(" ","");
var newstr = newstr.replace(" ","");
var newstr = newstr.replace(" ","");
var splitstr = newstr.split(",");
if(splitstr[1] === undefined){
document.getElementById
('tidMaaneder').innerHTML = 0;
document.getElementById
('tidDage').innerHTML = 0;
document.getElementById('tidTimer').innerHTML = 0;
document.getElementById
('tidMinutter').innerHTML = 0;
document.getElementById
('tidSekunder').innerHTML = splitstr[0];
if(splitstr[0] == 0){ location.reload
(true); }
}else if(splitstr[2] === undefined){
document.getElementById
('tidMaaneder').innerHTML = 0;
document.getElementById
('tidDage').innerHTML = 0;
document.getElementById('tidTimer').innerHTML = 0;
document.getElementById
('tidMinutter').innerHTML = splitstr[0];
document.getElementById
('tidSekunder').innerHTML = splitstr[1];
}else if(splitstr[3] === undefined){
document.getElementById
('tidMaaneder').innerHTML = 0;
document.getElementById
('tidDage').innerHTML = 0;
document.getElementById('tidTimer').innerHTML = splitstr[0];
document.getElementById
('tidMinutter').innerHTML = splitstr[1];
document.getElementById
('tidSekunder').innerHTML = splitstr[2];
}else if(splitstr[4] === undefined){
document.getElementById('tidMaaneder').innerHTML = 0;
document.getElementById('tidDage').innerHTML = splitstr
[0];
document.getElementById('tidTimer').innerHTML = splitstr
[1];
document.getElementById('tidMinutter').innerHTML =
splitstr[2];
document.getElementById('tidSekunder').innerHTML =
splitstr[3];
}else{
document.getElementById('tidMaaneder').innerHTML =
splitstr[0];
document.getElementById('tidDage').innerHTML = splitstr
[1];
document.getElementById('tidTimer').innerHTML = splitstr
[2];
document.getElementById('tidMinutter').innerHTML =
splitstr[3];
document.getElementById('tidSekunder').innerHTML =
splitstr[4];
}
}
</script>
Countdown.js
function rD_argsFailure(a){
return null;
}
function rD_twoDigits(num){
return (10>num)?"0"+num:""+num;
}
Date.prototype.age = function(d,ignoreTime,numFormat){
args = this.age.arguments;
if(args.length==0||args.length>=3&&typeof d != 'object')d = new Date();
if(typeof d != 'object' || !d.getTime){
return rD_argsFailure(typeof d);
}
if(d.getTime()>this.getTime()){
var f = d;
d = this;
}else
var f = this;
ignoreTime = (args.length==1||!args[1])?false:true;
var c = [1000,60,60,24];
var t = new Array();
t[t.length] = f.getFullYear() - d.getFullYear();
t[t.length] = f.getMonth() - d.getMonth();
t[t.length] = f.getDate() - d.getDate();
t[t.length] = f.getHours() - d.getHours();
t[t.length] = f.getMinutes() - d.getMinutes();
t[t.length] = f.getSeconds() - d.getSeconds();
t[t.length] = f.getMilliseconds() - d.getMilliseconds();
for(i=6;i>2;i--){
if(ignoreTime){
t[i] = 0;
}else if(0>t[i]){
t[i] += c[6-i];
t[i-1]--;
}
}
if(0>t[2]){
t[2] += new Date(f.getFullYear(),f.getMonth(),0).getDate();
t[1]--;
}
if(0>t[1]){
t[1] += 12;
t[0]--;
}
if(3>args.length || typeof args[2] != 'number' || 1 > args[2])
return [t[0],t[1],t[2],t[3],t[4],t[5],t[6]];
var ftxt,ret="",started=false;
if(typeof nedtaelling_tekst!='undefined'&&nedtaelling_tekst[5]!='undefined'){
ftxt = nedtaelling_tekst[5];
}else{
}
for(i=0;args[2]>i;i++){
if(!args[3]||t[i]!=0||started){
started = true;
ret += " ," + t[i] + " ";
}
}
return (ret=="")?'0 '+ftxt[i*2-1]:ret.substring(2);
}