Date Redirect + SSI -- Need help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • End Around

    #1

    Date Redirect + SSI -- Need help

    I am creating a time-based art web site that will show a different html
    page depending on the client side local date. I also prefer that the top
    page doesn't literally redirect to, say 7.htm for the 7th of May, but
    accesses that page via a Server Side Include or JS function. The work
    doesn't need a date stamp more complicated than "7.htm".

    I only know enough about Javascript to be dangerous. I have tried to
    bodge together what I could find online and on usenet without success.
    If someone could give me a hand with this, I would be happy to credit
    them on the site (whenever it goes live).

    Thanks to all who get this far,
    Ben
  • Lutz Ißler

    #2
    Re: Date Redirect + SSI -- Need help

    Hi Ben,

    End Around wrote:[color=blue]
    > I am creating a time-based art web site that will show a different html
    > page depending on the client side local date.[/color]

    Why do you want to use the client's local date? Using the server's date
    would be much easier when you want the client to invoke just a fixed URL
    like "art.html".

    In that case, you can use PHP or any other server-side language to
    determine the date and to display the appropriate page.

    Moreover, a server-side solution would be independent of the
    JavaScript-ability of the client's browser.
    [color=blue]
    > I only know enough about Javascript to be dangerous.[/color]

    If you really want to use the client date, try

    var dat = new Date();
    location.href = "path/to/you/html/"+dat.getDay()+ ".html";

    That would call pages like "7.html" on the 7th of May. Another solution
    would be

    var dat = new Date();
    location.href = "path/to/you/html/page.html?day=" +dat.getDay();

    which calls "page.html?day= 7".

    If you want to encode the client date to make the fact that the page is
    date-driven somewhat less obvious, do some calculations on the date, eg.

    var dat = new Date();
    var day = dat.getDay()*35 +17;
    location.href = "path/to/you/html/"+dat.getDay()+ ".html";

    On the server-side, you will have to revert this calculation by taking
    the encoded day number, subtracting 17, and dividing by 35.

    Regards,

    -.Lutz.-

    Comment

    • Dr John Stockton

      #3
      Re: Date Redirect + SSI -- Need help

      JRS: In article <3e69fgF1d5a6U1 @news.dfncis.de >, dated Sun, 8 May 2005
      12:54:37, seen in news:comp.lang. javascript, =?ISO-
      8859-15?Q?Lutz_I=DFl er?= <trash@lutzissl er.net> posted :
      [color=blue]
      >If you really want to use the client date, try
      >
      >var dat = new Date();
      >location.hre f = "path/to/you/html/"+dat.getDay()+ ".html";
      >
      >That would call pages like "7.html" on the 7th of May.[/color]

      It would never call for 7.html. Please test code before posting.
      [color=blue]
      > Another solution
      >would be
      >
      >var dat = new Date();
      >location.hre f = "path/to/you/html/page.html?day=" +dat.getDay();
      >
      >which calls "page.html?day= 7".[/color]

      It will never do that.
      [color=blue]
      >If you want to encode the client date to make the fact that the page is
      >date-driven somewhat less obvious, do some calculations on the date, eg.
      >
      >var dat = new Date();
      >var day = dat.getDay()*35 +17;
      >location.hre f = "path/to/you/html/"+dat.getDay()+ ".html";[/color]

      You're not using var day.
      [color=blue]
      >On the server-side, you will have to revert this calculation by taking
      >the encoded day number, subtracting 17, and dividing by 35.[/color]

      Not necessarily, if the possible values of day are correctly predicted
      and the pages named accordingly.


      D.getDate() -> 1..31
      D.getDay() -> 0..6

      --
      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
      <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

      Comment

      Working...