Different Page Displayed Depending on Day

Discussion in 'JavaScript' started by greggomatic76, May 23, 2007.

  1. #1
    Can anyone give me an idea on how to go about using javascript to change which page is shown depending on the date. Or if you know of a better way, help there would be appreciated. I am a beginner in java so my mistakes might be very stupid but I am giving it a whirl. This is what I tried with no success...

    <!--

    var day = currentTime.getDate()

    if (day = "23") {
    document.write("<META HTTP-EQUIV="Refresh" CONTENT="2; URL=http://www.google.com">")
    }

    --!>

    And then just an if else thing for each day of the month...
    That's the basics, probably butchered it so any pro help would be appreciated.
     
    greggomatic76, May 23, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    You can use something like this:

    
    <html>
    <head>
    <script language="javascript">
    
    var urlday  = [
      "http://www.yoursite.com/page-for-sunday.html",
      "http://www.yoursite.com/page-for-monday.html",
      "http://www.yoursite.com/page-for-tuesday.html",
      "http://www.yoursite.com/another.html",
      "http://www.yoursite.com/etc.html",
      "http://www.yoursite.com/friday.html",
      "http://www.yoursite.com/saturday.html" ];
      
    var today = new Date();  
    document.location = urlday[ today.getDay() ];
      
    </script>
    </head
    <body>
      To be redirected by javascript.
    </body>
    </html>
    
    Code (markup):
     
    ajsa52, May 23, 2007 IP
  3. greggomatic76

    greggomatic76 Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Awesome, worked like a charm! Thank you for your help!
     
    greggomatic76, May 24, 2007 IP