Creating temporary links that expire?

Discussion in 'Javascript' started by Levi, Jun 6, 2004.

  1. Levi

    Levi Guest

    I am developing a web site for a summer comedy series. The site has
    links to buy tickets but I want them to disappear two hours before the
    show begins. Does anyone know how to use a simple javascript that
    shows and hides text and links after a date has passed?

    lee317
    Levi, Jun 6, 2004
    #1
    1. Advertising

  2. Levi

    Lee Guest

    Levi said:
    >
    >I am developing a web site for a summer comedy series. The site has
    >links to buy tickets but I want them to disappear two hours before the
    >show begins. Does anyone know how to use a simple javascript that
    >shows and hides text and links after a date has passed?


    This example only hides the "buy" link after the date has passed
    (it actually checks to see if it's within 2 hours of the data/time).
    It assumes that you and your customers are within the same time
    zone and that there won't be a Daylight Saving Time change just
    before showtime. Older browsers and browsers that have javascript
    disabled will still see the link.


    <html>
    <head>
    <script type="text/javascript">
    var TWO_HOURS=7200000;
    function checkExpiry(img,dateString){
    var showTime=new Date(dateString);
    var now=new Date();
    if(img.parentNode && (showTime-now)<TWO_HOURS){
    img.parentNode.style.visibility="hidden";
    }
    }
    </script>
    </head>
    <body>
    <table>
    <tr>
    <td>Show 1</td>
    <td><a href="linkToBuyTickets.html"><img border="0"
    src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
    onload="checkExpiry(this,'Mon, 25 Dec 1995 13:30')"></a>
    </td>
    </tr>
    <tr>
    <td>Show 2</td>
    <td><a href="linkToBuyTickets.html"><img border="0"
    src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
    onload="checkExpiry(this,'Mon, 25 Dec 2004 13:30')"></a>
    </td>
    </tr>
    </table>
    </body>
    </html>
    Lee, Jun 6, 2004
    #2
    1. Advertising

  3. you could also do it in php.
    check php.net for date-calculation functions
    Matthias H. Risse, Jun 6, 2004
    #3
  4. Levi

    Levi Guest

    Thanks so much...this is perfect!

    Lee <> wrote in message news:<>...
    > Levi said:
    > >
    > >I am developing a web site for a summer comedy series. The site has
    > >links to buy tickets but I want them to disappear two hours before the
    > >show begins. Does anyone know how to use a simple javascript that
    > >shows and hides text and links after a date has passed?

    >
    > This example only hides the "buy" link after the date has passed
    > (it actually checks to see if it's within 2 hours of the data/time).
    > It assumes that you and your customers are within the same time
    > zone and that there won't be a Daylight Saving Time change just
    > before showtime. Older browsers and browsers that have javascript
    > disabled will still see the link.
    >
    >
    > <html>
    > <head>
    > <script type="text/javascript">
    > var TWO_HOURS=7200000;
    > function checkExpiry(img,dateString){
    > var showTime=new Date(dateString);
    > var now=new Date();
    > if(img.parentNode && (showTime-now)<TWO_HOURS){
    > img.parentNode.style.visibility="hidden";
    > }
    > }
    > </script>
    > </head>
    > <body>
    > <table>
    > <tr>
    > <td>Show 1</td>
    > <td><a href="linkToBuyTickets.html"><img border="0"
    > src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
    > onload="checkExpiry(this,'Mon, 25 Dec 1995 13:30')"></a>
    > </td>
    > </tr>
    > <tr>
    > <td>Show 2</td>
    > <td><a href="linkToBuyTickets.html"><img border="0"
    > src="http://www.azphx.com/dhtml/tmp/buy5025.gif"
    > onload="checkExpiry(this,'Mon, 25 Dec 2004 13:30')"></a>
    > </td>
    > </tr>
    > </table>
    > </body>
    > </html>
    Levi, Jun 7, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sudha
    Replies:
    1
    Views:
    302
  2. Jerry Spence1

    Creating temporary database on user's PC.

    Jerry Spence1, Dec 28, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    405
    Jerry Spence1
    Dec 28, 2004
  3. Denis Remezov
    Replies:
    23
    Views:
    661
    Benoit Mathieu
    Apr 17, 2004
  4. Replies:
    7
    Views:
    3,181
    James Kanze
    Feb 12, 2008
  5. Tongass Park Neighborhood Association, Juneau Alas

    Cookies expire immediately, not when set to expire

    Tongass Park Neighborhood Association, Juneau Alas, Oct 1, 2009, in forum: ASP General
    Replies:
    2
    Views:
    1,185
    SQLDude
    Nov 24, 2009
Loading...

Share This Page