Results 1 to 5 of 5

Thread: time specific content

  1. #1
    Join Date
    Oct 2005
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default time specific content

    I checked here on dynamic drive, jskit, and am right now checking a few other sites that popped up searching Google for free js scripts

    anyway, I was wondering if any of you guys have seen or know where I could get a script to make specified time specific content disappear (visibility?) at a certain date - I guess kinda like "if (current date > specified date) {specificID visibility = false;}" (still havent gotten to learning js, so I tried to make it look like ActionScript syntax, since they ought to be close together)

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's close enough. The first thing to understand is that it's far, far better to do this server-side.
    However, if you must do it client-side:
    Code:
    <script type="text/javascript">
    var dates = new Array(),  // Associative array
      now = new Date(),
      roughNow = Date.parse(now.getMonths() + "/" + now.getDays() + "/" + now.getFullYear());
    dates[0] = "12/25/2004:xmas04";
    dates[1] = "06/21/2005:litha05,tsanganniversary";
    for(var i=0;dates[i];i++) {
      var date = dates[i].substring(0, dates[i].indexOf(":")),
        ids = dates[i].substring(":" + 1).split(",");
      if(roughNow > Date.parse(date))
        for(var j=0;j<ids.length;j++)
          if(document.getElementById && document.getElementById(ids[j])) document.getElementById(ids[j]).style.display = "none";
    }
    </script>
    That should work. The format for a date entry is mm/dd/yy:id1[, id2 [, ...]]
    Last edited by Twey; 05-09-2006 at 06:56 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Oct 2005
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    what exactly would be the advantage(s) of doing it server side? if the advantages outweigh the trouble of doing it, could you point me to a site that has it cut-n-paste (or can show me how to do it myself) in ASP

    (stuck in miserable Frontpage - I'm feeling the effects of horrible MS formats right now, my boss sends me flyers in Publisher - doesnt even copy over to Word, let alone Frontpage, and barely saves correctly as an html document)

    aside from that, I hope this will fit my needs - then I'll just have to explain to my boss that the people browsing the site wont see expired content, it'll just show up in Frontpage/+code

  4. #4
    Join Date
    Oct 2005
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    something I just realized in the code you gave me - it says
    The format for a date entry is mm/dd/yy:id1[, id2 [, ...]]
    but then the code is
    25/12/2004
    06/21/2005
    so is it dd/mm/yy, or mm/dd/yy?

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Oh! My error, sorry. Edited. It wouldn't actually affect the script (the parser would notice that it was an invalid month and assume dd/mm/yyyy format, I believe) but it keeps things simple.

    what exactly would be the advantage(s) of doing it server side? if the advantages outweigh the trouble of doing it, could you point me to a site that has it cut-n-paste (or can show me how to do it myself) in ASP
    Unfortunately not. I don't know any ASP. The advantages would be:
    1) "Expired" content wouldn't actually be sent to the user, cutting down on bandwidth usage and keeping your code cleaner
    2) No Javascript dependence, and as a result a faster page loading time

    stuck in miserable Frontpage
    How so?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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