www.webdeveloper.com
Results 1 to 6 of 6

Thread: Easy way to activate hyperlink on a specific date?

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Easy way to activate hyperlink on a specific date?

    I have a page on which links become available on specific dates. Currently I am altering the anchor tag from:

    <! href="url">Whatever</a>

    to:

    <a href="url">Whatever</a>

    manually each time it is supposed to be available. My question is, is there simple code (html, css. etc.) that I can use to make the links "live" on the desired date?

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <meta name="Content-Style-Type" content="text/css">
    <title>Example</title>
    
    <script type="text/javascript">
    if (document.getElementById && new Date() > new Date ('16 August 2005')) onload = function () {
    	document.getElementById ('sometimes').removeChild (document.getElementById ('sometimes').firstChild)
    }
    </script>
    
    </head>
    <body>
    <p id="sometimes"><a href="http://www.w3c.org/">W3C</a></p>
    </body>
    </html>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Aug 2005
    Posts
    2

    Thanks, Charles

    Thanks for the code. Now, is there a way to specify a time as well as the date? Sorry for failing to mention time in original message. Does this change everything?

    madpsy

    p.s. I just tried out the previous script and it seems to be turning the link off not on at the specified date. When I set the date ahead one day ('17 August 2005') the link is re-activated.
    Last edited by madpsy; 08-16-2005 at 10:25 PM.

  4. #4
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    new Date() <= new Date

    Or other variations on the theme.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by ray326
    new Date() <= new Date

    Or other variations on the theme.
    Since time and dates are figuured to the nearest microsecond, you really don't need the "or equal to".
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Aug 2005
    Posts
    54
    Maybe I'm looking at this wrong, but it appears that you'd have to write up a bunch of different instances for the dates... wouldn't it be easier (as long as you have relatively few links) to simply do something like:

    <script language="javascript">
    if (<correct date>) {
    document.write( the link );
    }
    </script>

    ? Sorry that I don't have the exact code, never used the date function, and I'm just trying to give ideas here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles