Page background changes based on the time of day


Show a different image based on the time of day. In this example, a sun during the day, and the man in the moon at night.

<script language="JavaScript">
<!--
now = new Date();
hour = now.getHours(); 
if (hour > 4 && hour < 18) { 
document.bgColor = "#FFFFFF"; 
document.fgColor = "#000000"; 
document.write ("<center><img height = 150 width = 150 SRC = 'images/image1.gif'>");
document.write ("<p>No one wants to think about RSI - until the day they can't type anymore. Are you at risk?</center>");
}
else 
{ 
document.bgColor = "#000000"; 
document.fgColor = "#FFFFFF"; 
document.write ("<center><img height = 144 width = 515 SRC = 'images/image2.gif'>");
document.write ("<p>Is it the End of the World or just a great light show? Find out online. </center>");
}
// -->
</script>



Day and Night Javascript


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site