background for each day of the year?

Discussion in 'HTML & Website Design' started by janissarh, May 31, 2007.

  1. #1
    so i want a background that changes each day. and ideally i wouldnt' be using an array for this.. and instead could just do something like...

    var d = new Date()
    document.write("<body background='"d.getMonth(),d.getDate()".jpg'>")

    with the images in the same directory being named 01.jpg for jan 1st, 031.jpg for jan 31st, etc. etc.

    but i know nothing about the syntax or structure that that would require. i think my non-working example should at least explain what i want to accomplish... can someone tell me how i can do this? i know it's possible... i've seen every element i need in other scripts, but i just don't know how to make them all work together without getting a bunch of errors... :(

    p.s. this is actually on my windows desktop, not a website. it seems like some scripts won't work in an html set as the desktop background, but will on a webpage.. so thats weird too...
     
    janissarh, May 31, 2007 IP
  2. idotcom

    idotcom Well-Known Member

    Messages:
    522
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Not sure if this helps, but maybe you need to set the full path to the images

    like: C:\folder\01.jpg

    ???
     
    idotcom, May 31, 2007 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You need to attach the background to the existing BODY tag. If you use JavaScript in the manner you are suggesting, you'll be creating TWO body tags, which can really screw up the DOM, among other things.

    And I don't know about you, but I'd rather do this on the server-side, creating a custom stylesheet that would be dynamically generated at run time to place the background image on the body. Though this does have the draw-back of using the server's own clock rather than the user's (which is accessed through JavaScript's date object).
     
    Dan Schulz, May 31, 2007 IP
  4. idotcom

    idotcom Well-Known Member

    Messages:
    522
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Considering:
    How would you do it serverside if it's on the desktop?
     
    idotcom, May 31, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Install a Web server, of course. XAMPP is wonderful for this. :)
     
    Dan Schulz, May 31, 2007 IP