Thursday, November 27, 2008

Photo of the Day Javascript

I developed this Photo of the Day script a long time ago. What it does is that it displays a particular image for a certain day of the month. The code is very elementary javascript.


<script>
<!--
<!--Photo of the Day Script developed by: Eliza Magno (elizakirsten@gmail.com)-->
var grabDate = new Date(); //gets the date
var datex = grabDate.getDate(); //assigns date to variable
var monthx= grabDate.getMonth(); // assigns month to variable
var yearx = grabDate.getYear(); // assigns year to variable
monthx= monthx+1;


//next line of code finds and displays the image with a filename
//that corresponds to the present date, example: on january 1 the
//code will find 1.jpg in your images folder

document.write('<a href="images/'+datex+'.jpg" target=_blank><img src="images/'+datex+'.jpg" width=190 border=0></a>')


//next line of code displays the month/date
document.write('<font color="#717070"><br>'+monthx+'/'+datex+'</font>')

//-->
</script>



This script can be seen in action at Living Asia Channel.


No comments:

Post a Comment