How to hide link before countdown?

Discussion in 'Programming' started by erkanbs, Dec 18, 2006.

  1. #1
    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 :)
     
    erkanbs, Dec 18, 2006 IP
  2. Seph

    Seph Peon

    Messages:
    84
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    one way to do it would be to use javascript to fetch the link from the server asynchronously.
     
    Seph, Dec 18, 2006 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    
    <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):
     
    krakjoe, Dec 18, 2006 IP
    erkanbs likes this.
  4. erkanbs

    erkanbs Active Member

    Messages:
    207
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    im using java scripts on link and link have image. last code didnt work js and image?

    so any advice?
     
    erkanbs, Dec 19, 2006 IP
  5. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #5
    post the code you have exactly as it is on the page and tell me what you want it to do
     
    krakjoe, Dec 19, 2006 IP
  6. erkanbs

    erkanbs Active Member

    Messages:
    207
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #6
    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 :)
     
    erkanbs, Dec 19, 2006 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    
    <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):
    :)
     
    krakjoe, Dec 19, 2006 IP
  8. erkanbs

    erkanbs Active Member

    Messages:
    207
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #8
    you are great krakjoe :D thanks for eveythin :)
     
    erkanbs, Dec 19, 2006 IP
  9. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #9
    no problem :D
     
    krakjoe, Dec 19, 2006 IP
  10. erkanbs

    erkanbs Active Member

    Messages:
    207
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #10
    erkanbs, Dec 19, 2006 IP
  11. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #11
    your vars aren't being set by php in the javascript .....send me to a page without the countdown in
     
    krakjoe, Dec 19, 2006 IP
  12. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #12
    
    <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 ..... ????
     
    krakjoe, Dec 19, 2006 IP
  13. erkanbs

    erkanbs Active Member

    Messages:
    207
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #13
    didnt work i wanna cry :'(
     
    erkanbs, Dec 19, 2006 IP
  14. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #14
    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...
     
    krakjoe, Dec 19, 2006 IP
  15. TooHappy

    TooHappy Guest

    Messages:
    504
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Erkanbs,

    Did you give Joe green for his efforts? He deserves it!

    Cool to see the love here!
     
    TooHappy, Dec 19, 2006 IP
  16. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #16
    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):
     
    krakjoe, Dec 19, 2006 IP
  17. erkanbs

    erkanbs Active Member

    Messages:
    207
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #17
    krakjoe is great he solved my problem :) thanks again
     
    erkanbs, Dec 19, 2006 IP
  18. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #18
    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,
     
    Barti1987, Dec 19, 2006 IP
  19. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #19
    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......
     
    krakjoe, Dec 19, 2006 IP