1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

time delayed link?

Discussion in 'JavaScript' started by jnm, Jan 6, 2007.

  1. #1
    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?
     
    jnm, Jan 6, 2007 IP
  2. scriptur

    scriptur Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    this would have to be done server side instead of javascript. what programming language your site uses ?
     
    scriptur, Jan 7, 2007 IP
  3. jnm

    jnm Guest

    Messages:
    343
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    php / mysql
     
    jnm, Jan 8, 2007 IP
  4. kajakske

    kajakske Well-Known Member

    Messages:
    139
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    165
    #4
    Nono ... this can be done in javascript ...

    Example:

    setTimeout('EnableLinkHere()',4000);

    This will execute the EnableLinkHere() function after 4 seconds ...
     
    kajakske, Jan 9, 2007 IP
  5. jnm

    jnm Guest

    Messages:
    343
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i figured this, but i want an actual visual countdown timer that will countdown and at zero display the link...
     
    jnm, Jan 9, 2007 IP
  6. kajakske

    kajakske Well-Known Member

    Messages:
    139
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    165
    #6
    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):
     
    kajakske, Jan 10, 2007 IP
  7. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #7
    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):
     
    Logic Ali, Jan 12, 2007 IP
    jnm likes this.
  8. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #8
    <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):
     
    Logic Ali, Jan 14, 2007 IP