Users browsing this thread: 1 Guest(s)
JavaScript -> Auto-updating Image
#1
Remember how my sig used to have the daily Dilbert comic strip? That linked to an image that automatically updated itself, grabbing the image directly from the Dilbert website. Unfortunately, the way Dilbert's RSS worked changed, and apparently broke that.

I recently found a script by the same guy, which I'm pretty sure works. Thing is, I don't think there's an actual implementation of it anywhere that I link from. So I was wondering, anybody know how exactly I would go about doing something like this? Here's the code, it's in JavaScript.

Code:
<script>
    var now = new Date();
    var day = now.getDate();
    var month = now.getMonth() + 1;
    var year = now.getFullYear()%100;
    var dayofweek = (now.getDay() == 0) ? 's' : 'd';
    if (day < 10) day = '0' + day;
    if (month < 10) month = '0' + month;
    document.write('<img src="http://thedilbertstore.com/images/periodic_content/dilbert/dt' + year + '' + month + '' + day + dayofweek + 'hct.jpg">');
</script>

Ideally I would want to be able to put it in a file or something and link it from my Dropbox, if possible. If an actual web domain is required that could be a bit tricky for me. Either way, I just want to know how to do this at all.
You may have a fresh start any moment you choose, for this thing that we call "failure" is not the falling down, but the staying down. -Mary Pickford
Thanked by:


Messages In This Thread
JavaScript -> Auto-updating Image - by puggsoy - 11-06-2013, 03:51 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-08-2013, 10:58 AM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-08-2013, 04:28 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-08-2013, 02:38 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-08-2013, 08:48 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-09-2013, 07:18 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-09-2013, 10:32 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-09-2013, 10:56 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-09-2013, 11:16 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-10-2013, 01:38 AM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-10-2013, 10:58 AM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-10-2013, 03:04 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-10-2013, 06:37 PM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-11-2013, 02:03 AM
RE: JavaScript -> Auto-updating Image - by Phaze - 11-11-2013, 07:16 PM

Forum Jump: