Here's a more robust example:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
background-color: transparent;
}
</style>
<script type="text/javascript">
/* Time of Day Background Script ©2009 John Davenport Scheuer
as first seen in http://www.dynamicdrive.com/forums/
username: jscheuer1 - This Notice Must Remain for Legal Use
*/
(function(){
var now, pics = {
morning: 'http://i19.tinypic.com/2mdl82c.jpg',
afternoon: 'http://s4.tinypic.com/2u55qj8_th.jpg',
night: 'http://s4.tinypic.com/2qkqjjt_th.jpg',
show: function(){
return now > 5 && now < 12? this.morning : now > 11 && now < 19? this.afternoon : this.night;
}
};(function(){
now = new Date().getHours();
document.documentElement.style.backgroundImage = 'url(' + pics.show() + ')';
if(typeof pics.interval === 'undefined'){
pics.interval = setInterval(arguments.callee, 10000);
}
})();
})();
</script>
</head>
<body>
</body>
</html>
Bookmarks