Daily comic wallpaper help!

Discussion in 'Desktop Customisation' started by da8om8, Sep 11, 2003.

  1. da8om8

    da8om8 Guest

    Currently, my desktop is an html page that shows new comics on it every day (from www.ucomics.com)

    The coding is shown at the end of this message (I copied it from another forum: I don't know much about javascript or html :(). The URL for the comics are different everyday (to avoid leeching i guess :D) and the URL itself contains the date in a strange format (year/month/date).

    The problem: On the 1st day of every month, it gets the date wrong & hence the comics wont load - eg on the 1st of October it will think thats its the 31st of September :mad:

    The desktop works fine for every other day, and u can see from the attached screenshot.

    Thanks in advance!!

    Coding for desktop:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <script language="JavaScript1.2">

    function reset_image(name, pad) {

    today = new Date();
    if (pad > 0) {
    today = new Date(today.getTime() - pad);
    }

    year = today.getYear();
    if (year > 2009) {
    year -= 2000;
    year = new String(year);
    }
    else if (year > 2000) {
    year -= 2000;
    year = '0' + new String(year);
    }
    else if (year > 9) {
    year = '0' + new String(year);
    }
    else {
    year = new String(year);
    }

    if (today.getMonth() > 8) {
    month = new String(today.getMonth() + 1);
    }
    else {
    month = '0' + new String(today.getMonth() + 1);
    }

    if (today.getDate() > 8) {
    day = new String(today.getDate() + 1);
    }
    else {
    day = '0' + new String(today.getDate() + 1);
    }

    setTimeout("reset_image('" + name + "', 0)", 3600000);
    if (name == 'penny') {
    url = 'http://images.ucomics.com/comics/tmani/20' + year + '/tmani' + year + month + day + '.gif';
    }
    else if (name == 'garfield') {
    url = 'http://images.ucomics.com/comics/ga/20' + year + '/ga' + year + month + day + '.gif';
    }
    eval('document.' + name + '_invisible.src = url');
    }

    </script>
    </head>
    <body bgcolor="#34629e"
    onload="reset_image('penny', 86400000);reset_image('garfield', 86400000);"
    background="rebirth_1024.jpg">
    <table width="100%" height="100%" border="0">
    <tbody>
    <tr height="0">
    <td align="right" valign="top"> <img name="penny_invisible" src=""
    onload="document.penny_visible.src=this.src" width="0" height="0"
    style="visibility: hidden;"> <img name="penny_visible"
    alt=""> </td>
    </tr>
    <tr height="0">
    <td align="right" valign="bottom"> <img name="garfield_invisible"
    src="" onload="document.garfield_visible.src=this.src" width="0"
    height="0" style="visibility: hidden;"> <img name="garfield_visible"
    alt=""> </td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>
     
  2. grimman

    grimman Guest

    I've seen this before. The problem then was that the dates from 01 to 09 weren't prefixed with zero... mwell. My suggestion is for you to work something out in ASP or PHP. But then again, I'm more experienced with those two than I am with JavaScript so I don't really know all you can do. ;>
     
  3. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England