anyone know how to create a countdown timer before a link can be active... rapidshare.de uses this on free accounts before you can download a file?
this would have to be done server side instead of javascript. what programming language your site uses ?
Nono ... this can be done in javascript ... Example: setTimeout('EnableLinkHere()',4000); This will execute the EnableLinkHere() function after 4 seconds ...
i figured this, but i want an actual visual countdown timer that will countdown and at zero display the link...
Oh, sorry I misunderstood I guess ... <head> <script> var count = 5; function CountDown() { document.getElementById("count").value = count; if (count > 0) { setTimeout('CountDown()',1000); } else { document.getElementById("link").style.display = "block"; } count--; } </script> </head> <body onload="CountDown();"> <input type="text" id="count"> <div id="link" style="display:none"> Woohoo this link : <a href="http://www.google.com">Google</a> </div> </body> Code (markup):
I did this for someone on another forum recently. Here's a working demo page: <HTML> <HEAD> <TITLE>Delayed Links</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> </HEAD> <BODY> <A HREF="#" name='ytLink'>Top</A><BR><BR> <A HREF="#" name='gLink'>Top</A><BR><BR> <A HREF="#" name='opLink'>Top</A> <SCRIPT type='text/javascript'> function delayLink(linkName, secs, waitText, finalURL, finalText) { for(var j=0; j<document.links.length && document.links[j].name!=linkName; j++) ; /*I.E. won't index a link by name, so get its offset.*/ if(j!=document.links.length && document.links[0].childNodes) { for(var i=secs; i>-1; i--) setTimeout("document.links[\'"+j+"\'].childNodes[0].nodeValue=\'"+waitText+" "+(secs-i)+" second"+((secs-i==1)?"":"s")+"\'", i*1000); setTimeout("document.links[\'"+j+"\'].childNodes[0].nodeValue=\'"+finalText+"\';document.links[\'"+j+"\'].href=\'"+finalURL+"\'", secs*1000); } } delayLink('ytLink', 5, "Please wait", "http://youtube.com", "YouTube"); delayLink('gLink', 8, "Google in", "http://google.com", "Google!"); delayLink('opLink', 11, "This link will point to Opera.com in", "http://www.opera.com", "Opera"); </SCRIPT> </BODY> </HTML> Code (markup):
<SCRIPT type='text/javascript'> function delayLink(linkName, secs, waitText, finalURL, finalText, linkRel) { if(linkRel==undefined) linkRel=''; for(var j=0; j<document.links.length && document.links[j].name!=linkName; j++) ; /*I.E. won't index a link by name, so get its offset.*/ if(j!=document.links.length && document.links[0].childNodes) { for(var i=secs; i>-1; i--) setTimeout("document.links["+j+"].childNodes[0].nodeValue=\'"+waitText+" "+(secs-i)+" second"+((secs-i==1)?"":"s")+"\'", i*1000); setTimeout("document.links["+j+"].childNodes[0].nodeValue=\'"+finalText+"\';document.links[\'"+j+"\'].href=\'"+finalURL+"\';document.links["+j+"].rel=\'"+linkRel+"\'", secs*1000); } } delayLink('ytLink', 5, "Please wait", "http://youtube.com", "YouTube"); delayLink('gLink', 8, "Google in", "http://google.com", "Google!"); delayLink('opLink', 11, "This link will point to Opera.com in", "http://www.opera.com", "Opera", "alternate"); /** If required, REL may be specified as an OPTIONAL sixth parameter as shown. **/ </SCRIPT> Code (markup):