السبت، 14 أبريل 2012

Different background image according to time of day

Cut & Paste Different background image according to time of day
Description: A simple script that changes the background image of the document four times a day, depending on the time period. The periods are : 12pm to 4am, 4am to 12am, 12am to 6pm, and 6pm to 12pm.

 Insert the below into the <HEAD> section of your page:

<script language="JavaScript">

day=new Date()     //..get the date

x=day.getHours()    //..get the hour

if(x>=0 && x<4) {

   document.write('<style type="text/css">body{background: white url(1st.jpg); color: black}"></style>')

} else

if(x>=4 && x<12) {

   document.write('<style type="text/css">body{background: white url(2nd.jpg); color: black}</style>')

} else

if(x>=12 && x<18) {

   document.write('<style type="text/css">body{background: white url(3rd.jpg); color: black}</style>')

} else

if (x>=18 && x<24) {

   document.write('<style type="text/css">body{background: white url(4th.jpg); color: black}</style>')

}

</script>

ليست هناك تعليقات:

إرسال تعليق