Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

heisenberg123

macrumors 603
Original poster
Oct 31, 2010
6,498
9
Hamilton, Ontario
Looking to make my own lockscreen theme that has a wallpaper that changes every so often, say every 20 mins.


i cant find a tutorial on this anywhere
 
Here's the code I wrote that does it. I was trying to have the background mimic the time of day.

Code:
<!-- change background script-->
<script language="JavaScript">


day=new Date(); //..get the date
x=day.getHours(); //..get the hour


if(x>=0 && x<6) {
document.write('<style type="text/css">body{background: white url(Wall/night.jpg); color: black}</style>');
} else

if(x>=6 && x<8) {
document.write('<style type="text/css">body{background: white url(Wall/sunrise.jpg); color: black}</style>');
} else

if(x>=8 && x<11) {
document.write('<style type="text/css">body{background: white url(Wall/morning.jpg); color: black}</style>');
} else

if(x>=11 && x<14) {
document.write('<style type="text/css">body{background: white url(Wall/day.jpg); color: black}</style>');
} else

if(x>=14 && x<17) {
document.write('<style type="text/css">body{background: white url(Wall/afternoon.jpg); color: black}</style>');
} else

if(x>=17 && x<19) {
document.write('<style type="text/css">body{background: white url(Wall/sunset.jpg); color: black}</style>');
} else

if(x>=19 && x<20) {
document.write('<style type="text/css">body{background: white url(Wall/evening.jpg); color: black}</style>');
} else

if (x>=20 && x<24) {
document.write('<style type="text/css">body{background: white url(Wall/night.jpg); color: black}</style>');
}
</script>
 
Here's the code I wrote that does it. I was trying to have the background mimic the time of day.

Code:
<!-- change background script-->
<script language="JavaScript">


day=new Date(); //..get the date
x=day.getHours(); //..get the hour


if(x>=0 && x<6) {
document.write('<style type="text/css">body{background: white url(Wall/night.jpg); color: black}</style>');
} else

if(x>=6 && x<8) {
document.write('<style type="text/css">body{background: white url(Wall/sunrise.jpg); color: black}</style>');
} else

if(x>=8 && x<11) {
document.write('<style type="text/css">body{background: white url(Wall/morning.jpg); color: black}</style>');
} else

if(x>=11 && x<14) {
document.write('<style type="text/css">body{background: white url(Wall/day.jpg); color: black}</style>');
} else

if(x>=14 && x<17) {
document.write('<style type="text/css">body{background: white url(Wall/afternoon.jpg); color: black}</style>');
} else

if(x>=17 && x<19) {
document.write('<style type="text/css">body{background: white url(Wall/sunset.jpg); color: black}</style>');
} else

if(x>=19 && x<20) {
document.write('<style type="text/css">body{background: white url(Wall/evening.jpg); color: black}</style>');
} else

if (x>=20 && x<24) {
document.write('<style type="text/css">body{background: white url(Wall/night.jpg); color: black}</style>');
}
</script>

thanks for sharing your code, java script gives me nightmares lol
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.