Gå til innhold

[Løst]Firefox viser ikkje javascript - feil i kode?


Anbefalte innlegg

Hei,

Eg har laga ei side som enkelt nok tel ned til helg. Scriptet har eg lånt fra ei anna side, men det ser ikkje ut til å fungere i Firefox - uten at eg aner kvifor. Kan nokon hjelpe meg å sjå kva problemet kan vere? Koden kjem her:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="title" content="Nedtelling til helg!" />
<meta name="description" content="En enkel men elegant side som teller ned til ukens høydepunkt - nemlig helgen! " />
<link rel="image_src" href="http://www.steffenmedia.no/helg/facethumb.jpg" />

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Nedtelling til helg!</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="./fancybox/jquery.fancybox-1.2.6.css" media="screen" />
<script type="text/javascript" src="./fancybox/jquery.fancybox-1.2.6.pack.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("a.zoom").fancybox();

		$("a.zoom1").fancybox({
			'overlayOpacity'	:	0.7,
			'overlayColor'		:	'#FFF'
		});

		$("a.zoom2").fancybox({
			'zoomSpeedIn'		:	500,
			'zoomSpeedOut'		:	500
		});
	});
</script>
<style type="text/css">


body {
margin:0;
padding:0;
background: url(back.png) repeat-x #fff;
}
* {
margin:0;
padding:0;
}

#logo {
width:400px;
height:240px;
margin-left:35%;
margin-top:150px;
}
#innhold {
width:400px;
margin-left:35%;
text-align: center;
font-size:16px;
font-weight:bold;
}

#statistikk {
margin-left:28%;
margin-top:200px;
position: absolute;
bottom:20px;
font-family:verdana;
font-size:12px;
}

a {
color:#aaa;
text-decoration: none;
}
a:hover {
color:#000;
text-decoration: underline;
}
#bmeny ul {
list-style: none;
}

#bmeny li {
display:inline;
padding-left:10px;
}

</style>
</head>
<body>
<script type="text/javascript">
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.getFullYear() - 2000;
	 Todays_Month = Today.getMonth();				  

	 //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 - 1, 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.all.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 = 'er'; hps = 'r'; mps = 'er'; sps = 'er';
				//ps is short for plural suffix.
				if(days == 1) dps ='';
				if(hours == 1) hps ='';
				if(minutes == 1) mps ='';
				if(seconds == 1) sps ='';

				document.all.countdown.innerHTML = days + ' dag' + dps + ' ';
				document.all.countdown.innerHTML += hours + ' time' + hps + ' ';
				document.all.countdown.innerHTML += minutes + ' minutt' + mps + ' og ';
				document.all.countdown.innerHTML += seconds + ' sekund' + sps;
				break;
		   default: 
				document.all.countdown.innerHTML = Time_Left + ' seconds';
		   }

	 //Recursive call, keeps the clock ticking.
	 setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
	 }
</script>
<?php 
// Lag utregning til helg i prosent
$engelskdag = date('l');

switch ($engelskdag) {
case "Monday":
$dagverdi = "1";
break;

case "Tuesday":
$dagverdi = "2";
break;

case "Wednesday":
$dagverdi = "3";
break;

case "Thursday":
$dagverdi = "4";
break;

case "Friday":
$dagverdi = "5";
break;
}
$dageriuken = "5";
// Regne om til prosent
$prosentcount = $dagverdi / $dageriuken * 100;
$matrise = explode(".", $prosentcount);
$prosent_igjen = 100 - $prosentcount;
$dager_igjen = $dageriuken - $dagverdi;


// Generere dato til helg
$datoen_idag = date("d") + $dager_igjen;
$aret_iar = date("y");
$maneden_naa = date("m");
//echo $dager_igjen;


?>
<div id="logo"><img src="logos.png"></div>
<div id="innhold">
<script type="text/javascript">countdown_clock(<?php echo $aret_iar ?>, <?php echo $maneden_naa ?>, <?php echo $datoen_idag ?>, 16, 00, 1);</script>
<script type="text/javascript">countdown_clock(10, 02, 05, 16, 00, 1);</script>igjen til neste helg!
</div>


<div id="statistikk">
<div id="bmeny"><ul>
<li><a name="fb_share" type="icon_link" href="http://www.facebook.com/sharer.php">DEL PÅ FACE</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></li>
<li><a class="zoom1" href="hva.php">OM EN VISJON</a></li>
<li><a class="zoom1" href="hvordan.php">HVORDAN FUNGERER DET?</a></li>
<li><a href="feedback.php">GI OG LES TILBAKEMELDINGER</a></li>
</ul></div>
</div>
</body>
</html>

 

Dei kan sjå eit døme på denne adressa..

Takker for alle svar.

Lenke til kommentar
Videoannonse
Annonse

Tror ikke Firefox støtter document.all i og med at dette er en gammel metode som ikke lenger er standard.

 

Det du kan bytte den ut med er document.getElementById().

 

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.getFullYear() - 2000;
	 Todays_Month = Today.getMonth();				  

	 //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 - 1, 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 = 'er'; hps = 'r'; mps = 'er'; sps = 'er';
				//ps is short for plural suffix.
				if(days == 1) dps ='';
				if(hours == 1) hps ='';
				if(minutes == 1) mps ='';
				if(seconds == 1) sps ='';

				document.getElementById("countdown").innerHTML = days + ' dag' + dps + ' ';
				document.getElementById("countdown").innerHTML += hours + ' time' + hps + ' ';
				document.getElementById("countdown").innerHTML += minutes + ' minutt' + mps + ' og ';
				document.getElementById("countdown").innerHTML += seconds + ' sekund' + sps;
				break;
		   default:
				document.getElementById("countdown").innerHTML = Time_Left + ' seconds';
		   }

	 //Recursive call, keeps the clock ticking.
	 setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
	 }

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...