Jump to content

Help with countdown timer


Gutspiller

Recommended Posts

I have googled and found most of the work, but I know nothing about javascript.

 

This timer counts down and displays the timer, then the timer disappears and displays a text link.

 

For the life of me I can't figure out how to get it to have text before the timer though, but still disappear when the timer does.

 

So it would say something like "Your download will be ready in 15 seconds." And the 15 counts down, but the rest of the words stay the same. Then just like the code already does, it disappears and displays the download link.

 

I've pasted the code below. Can somebody please help me with what I need to add and where?

 

Thanks for any help!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Count Down Link - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.cent {
text-align:center;
margin:0 auto;
}
</style>
<script type="text/javascript">
document.write('<style type="text/css">#timed{display:none;}<\/style>')
function delay_link(){
var d=delay_link, t=document.getElementById('timed'); 
if(d.c&&d.c.nodeValue.replace(/[^\d]*/,'')-1>0){
d.c.nodeValue='\xa0\xa0'+(d.c.nodeValue.replace(/[^\d]*/,'')-1);
setTimeout('delay_link()', 1000)
return;
}
else if(!d.c){
d.c=document.createTextNode('10');
t.parentNode.insertBefore(d.c,t);
setTimeout('delay_link()', 1000)
return;
}
d.c.nodeValue='';
t.style.display='inline';
}
</script>
</head>
<body>
<div class="cent"><a id="timed" href='http://www.download.com/dsplus/ds.php?p=<filename />&t=<token />'>Click Here to start your download</a></div>
<script type="text/javascript">delay_link();</script>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/146079-help-with-countdown-timer/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.