hi everybody i need a little script for my downlaod links. in my site link have download image. when click image, new window opens and download starts. i just wanna hide my link for 5 (or 10 sec.) . for example: please wait 5...4...3...2...1...0 and download link (image) appears i think like rapidshare's countdown. thanks for help
<div id="counterDiv"> 10 seconds </div> <script> var countdownfrom=10 // seconds to countdown var currentsecond=counterDiv.innerHTM=countdownfrom+1 function counter() { if (currentsecond!=1) { currentsecond-=1 counterDiv.innerHTML=currentsecond + ' seconds' } else{ document.getElementById("counterDiv").innerHTML = "<a href='http://google.com'>Google</a>"; return } setTimeout("counter()",1000) } counter() </script> Code (markup):
my site is www.echomp3.com an sample download link http://www.echomp3.com/mp3-Slipknot--Duality--214.html . there is an .gif image bottom of the page. when you click it opens a popup and download page my downlaod link code <a href="javascript:;" onclick="indir(<?=$id;?>,'<?=$is;?>')"> <img border="0" src="images/indir.gif" style="border: 1px solid #808080; background-color: #FFFFFF" width="200" height="40"></a> PHP: thanks for help
<div id="counterDiv"> 10 seconds </div> <script> var countdownfrom=10 // seconds to countdown var currentsecond=counterDiv.innerHTM=countdownfrom+1 var LinkStr = '<a href="#" onclick="indir(<?=$id;?>, <?=$is;?>)"><img border="0" src="images/indir.gif" style="border: 1px solid #808080; background-color: #FFFFFF" width="200" height="40"></a>'; function counter() { if (currentsecond!=1) { currentsecond-=1 counterDiv.innerHTML=currentsecond + ' seconds' } else{ document.getElementById("counterDiv").innerHTML = LinkStr; return } setTimeout("counter()",1000) } counter() </script> Code (markup):
i think there is an problem too after countdown link doesnt work example: http://www.echomp3.com/mp3-Anti-Flag--Fuck_Police_Brutality--385.html
<div id="counterDiv"> 10 seconds </div> <script> var countdownfrom=10 // seconds to countdown var currentsecond=counterDiv.innerHTM=countdownfrom+1 var id = <?=$id ?>; var is = <?=$is ?>; var LinkStr = '<a href=\'javascript:indir("'+id+'", "'+is+'");\' ><img border="0" src="images/indir.gif" style="border: 1px solid #808080; background-color: #FFFFFF" width="200" height="40"></a>'; function counter() { if (currentsecond!=1) { currentsecond-=1 counterDiv.innerHTML=currentsecond + ' seconds' } else{ document.getElementById("counterDiv").innerHTML = LinkStr; return } setTimeout("counter()",1000) } counter() </script> Code (markup): oops, try that ..... ????
u have the counter script in the page twice, it's probably calling the first one which is the first snippet I posted, tidy up the html and it really should work, the variables get though and the script is executed I tried with a fake alert function...
and the finally working code is <div id="counterDiv"> 20 seconds </div> <script> var countdownfrom=20 // seconds to countdown var currentsecond=counterDiv.innerHTM=countdownfrom+1 var id = '<?=$id ?>'; var is = '<?=$is ?>'; var LinkStr = '<a href=\'javascript:indir("'+id+'", "'+is+'");\' ><img border="0" src="images/indir.gif" style="border: 1px solid #808080; background-color: #FFFFFF" width="200" height="40"></a>'; function counter() { if (currentsecond!=1) { currentsecond-=1 counterDiv.innerHTML=currentsecond + ' seconds' } else{ document.getElementById("counterDiv").innerHTML = LinkStr; return } setTimeout("counter()",1000) } counter(); </script> Code (markup):
Please note that this only hides it from normal users (I always view source and get the link), but its pretty much suits me on my free file hosting service. Peace,
by the time you have viewed the source and executed js in the address bar you might has well have just waited the 10 seconds to download......