Script modificare fundal dupa ore
Posted: 03 Dec 2013, 12:25
Dupa cum spune si titlul, este un script care schimba valoarea fundalului in functie de ore, il puteti seta sa schimbe culoarea/imaginea fundalului la o anumita ora sau il puteti clasifica in doua perioade, noapte si zi.
Se aduga inainte de <body> intre <head> si </head>:
Daca aveti intrebari nu ezitati sa ma intrebati.
Se aduga inainte de <body> intre <head> si </head>:
Code: Select all
<script type="text/javascript">
<!--
var now = new Date();
var hours = now.getHours();
var psj=0;
document.write('<style type="text/css">')
//18-19 noaptea
if (hours > 17 && hours < 20){
document.write('body{background:orange; color:#FFFFFF;} a{color: yellow !important}')
}
//20-21 noaptea
if (hours > 19 && hours < 22){
document.write('body{background:orangered; color:#FFFFFF;} a{color: yellow !important}')
}
//22-4 noaptea
if (hours > 21 || hours < 5){
document.write('body{background:black; color:#FFFFFF;} a{color: yellow !important}')
}
//9-17 ziua
if (hours > 8 && hours < 18){
document.write('body{background:deepskyblue; color:#FFFFFF;} a{color: yellow !important}')
}
//7-8 ziua
if (hours > 6 && hours < 9){
document.write('body{background:skyblue; color:#FFFFFF;} a{color: yellow !important}')
}
//5-6 ziua
if (hours > 4 && hours < 7){
document.write('body{background:steelblue; color:#FFFFFF;} a{color: yellow !important}')
}
document.write('<\/style>')
//-->
</script>