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
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.