...

View Full Version : Javascript Countdown Timer



benbarnett
03-04-2005, 03:31 PM
I have set up a slideshow that uses both PHP and Javascript. The PHP side of it obviously works on all browsers. However, when the 'Start' button is pressed, it triggers javascript to create countdown timer of 5 seconds, before it moves to the next image.

This works absolutely fine on IE, but on Firefox - nothing happens.

Does anyone know of a way round this, or how to create a countdown timer that will function in Firefox/Mozilla? :)

You can see the page that works in IE at http://www.gardensbydesignuk.co.uk/gbd/p_hauf.php

Xko
03-04-2005, 03:43 PM
My only useful information here is that good old hotscripts.com has 20 javascript countdown timers.

Maybe one of those will suit your requirements?

Clicky Clicky! (http://www.hotscripts.com/JavaScript/Scripts_and_Programs/Countdowns/index.html)

benbarnett
03-04-2005, 04:16 PM
I've done a bit more testing and found that I don't think it's the timer that's causing the problem.

Here's the JS code.. Start() is called when the start button is clicked.



<script language="javascript1.2">
var secs;
var count;

function Start() {
secs="5";
setTimeout("countDown()",1000);
document.getElementById("play_img").src="images/slide_pause.gif";
document.getElementById("play_img").alt="Pause Slideshow";
document.getElementById("play_a").href="javascript:Stop();";
document.getElementById("progbar").width="80";
}

function Stop() {
if (count) { clearTimeout(count); }
document.getElementById('play_img').src='images/slide_play.gif';
document.getElementById('play_img').alt='Start Slideshow';
document.getElementById('play_a').href="javascript:Start();";
document.getElementById('progbar').width='0';
}
function countDown() {
if(secs==0) { return; }
secs--;
document.getElementById('progbar').width=(document.getElementById('progbar').width-(80/5));
if(secs<1) { nextImage(); return; }
count=setTimeout("countDown()",1000);
}
</script>

benbarnett
03-07-2005, 01:56 PM
No worries.. just made a flash alternative; much better option anyway.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum