Snippet Name: Countdown to Enable a Download Link
Description: How to enable a link after a set period of time (in this case, 30 seconds). After the countdown period is over the content in the "tmx" div is changed to contain the link.
<script type="text/Javascript"> xcounter=30; function countdown(){ if ((0 <= 100) || (0 > 0)) { xcounter--; if(xcounter== 0){ document.getElementById("tmx").innerHTML = '<a href="http://www.somedomain.com/somepage.htm">Click to Download</a>'; } if(xcounter> 0){ document.getElementById("tmx").innerHTML = 'Please wait <b>'+xcounter+'</b> seconds...'; setTimeout('countdown()',1000); } } } countdown(); </script> <div id="tmx"> </div>
No comments:
Post a Comment