Timed Background Change HTML Code?

Discussion in 'Web Design & Coding' started by Brando16, Nov 13, 2006.

  1. Brando16

    Brando16 The Mixed Bag

    Joined:
    Apr 26, 2003
    Messages:
    96
    Likes Received:
    1
    Location:
    Anywhere
    Hey everyone, it's been a while! Here's a challenge.

    I've fallen into the MySpace craze...and I want to do something unique for a background. I'd like to set it up so that during the day (6AM-6PM) one background displays, and then during the night (6PM-6AM) a different background shows instead. This way, I can make a day/night version of the same picture and it can automatically change itself.

    I've searched for HTML code, but have only found PHP code. Myspace says no to PHP, so I'm stuck with HTML only for now. I've searched all around for such a code, and have had no leads. Can anyone here code this?
     
    Brando16, Nov 13, 2006
    #1
    1. Advertisements

  2. Brando16

    Codex85 Mouse Potato VIP Member

    Joined:
    Apr 19, 2005
    Messages:
    776
    Likes Received:
    18
    Location:
    US
    I trust this is fairly self-explanatory.

    Code:
    <script type="text/javascript" language="JavaScript">
    <!--
    var date = new Date();
    var time = date.getHours();
    if (time >= 6 && time < 18) {document.body.background = 'DayImage.jpg'}
    else {document.body.background = 'NightImage.jpg'}
    -->
    </script>
    
     
    Codex85, Nov 13, 2006
    #2
    1. Advertisements

  3. Brando16

    Goober THQ's Jester Moderator

    Joined:
    Jul 26, 2004
    Messages:
    2,864
    Likes Received:
    35
    Location:
    Colorado
    I would agree with the code but Java is not allowed :p
     
    Goober, Nov 13, 2006
    #3
  4. Brando16

    Codex85 Mouse Potato VIP Member

    Joined:
    Apr 19, 2005
    Messages:
    776
    Likes Received:
    18
    Location:
    US
    Really? He said PHP was disallowed, which I took to mean JS was okay (completely ignoring the "HTML only" part of the post, which proves that it was late and I was tired).

    If there's an HTML/CSS only solution to this, I'd love to see it, but there's no way I know of to pull the time and use it to change anything without some scripting (whether in PHP or Java).
     
    Codex85, Nov 13, 2006
    #4
  5. Brando16

    Crimson Devil's Advocate VIP Member

    Joined:
    Aug 21, 2006
    Messages:
    479
    Likes Received:
    3
    Location:
    Norfolk, VA
    HTML only can't do it. You would need either Java or some other script form.

    I thought JavaScript was good on myspace? Maybe someone needs to knock some reality into Tom.
     
    Crimson, Nov 13, 2006
    #5
  6. Brando16

    Brando16 The Mixed Bag

    Joined:
    Apr 26, 2003
    Messages:
    96
    Likes Received:
    1
    Location:
    Anywhere
    That Javascript might actually work, Crimson - you're right! I've had success with Javascript in MySpace, so I'll give it a shot. I didn't think it was possible with HTML only either, but know it can't be PHP because MySpace is HTML only.

    Thanks for the quick reply! Will post again with results shortly.
     
    Brando16, Nov 15, 2006
    #6
  7. Brando16

    Goober THQ's Jester Moderator

    Joined:
    Jul 26, 2004
    Messages:
    2,864
    Likes Received:
    35
    Location:
    Colorado
    I do not see why you cannot use PHP. :S
     
    Goober, Nov 15, 2006
    #7
  8. Brando16

    TheOneGreatX VIP Member

    Joined:
    Apr 27, 2004
    Messages:
    1,276
    Likes Received:
    16
    Location:
    US
    MySpace just doesn't use any PHP whatsoever. They may not even have it installed on their servers.
     
    TheOneGreatX, Nov 15, 2006
    #8
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.