Come avrete ben notato, oggi ho aggiunto al sito la funzione:
Seleziona sfondo :P
Questa funzione è stata scritta da me in javascript.
Ma come funziona ?
In sostanza questa funzione,viene attivata, quando viene spuntata la checkbox e modifica il css, e nel mio caso lo sfondo ;)
Questa è il principio:
document.styleSheets[0].cssRules[0].style.background="IMMAGINE ";
Dove:
document.styleSheets[0] : è il nostro css( il primo) ;
Spero che vi possa essere utile :P
Sorgente:
function blue(){
document.cookie="colore=blue;";
document.styleSheets[1].cssRules[0].style.background="#FFF url(http://www.clshack.it/wp-content/themes/clshack/img/body3.png) repeat top";
document.getElementById('blue').checked=true;
document.getElementById('red').checked=false;
}
function red(){
document.cookie="colore=red;";
document.styleSheets[1].cssRules[0].style.background="#FFF url(http://www.clshack.it/wp-content/themes/clshack/img/body2.png) repeat top";
document.getElementById('blue').checked=false;
document.getElementById('red').checked=true;
}
function getCookie( name ) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return(null);
if (start == -1) return(null);
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return(unescape(document.cookie.substring(len,end)) );
}
window.onload=function()
{
if (getCookie('colore')=="blue"){
document.styleSheets[1].cssRules[0].style.background="#FFF url(http://www.clshack.it/wp-content/themes/clshack/img/body3.png) repeat top";
document.getElementById('blue').checked=true;
}
else if (getCookie('colore')=="red"){
document.styleSheets[1].cssRules[0].style.background="#FFF url(http://www.clshack.it/wp-content/themes/clshack/img/body2.png) repeat top";
document.getElementById('red').checked=true;
}
else {
document.styleSheets[1].cssRules[0].style.background="#FFF url(http://www.clshack.it/wp-content/themes/clshack/img/body.png) repeat top";
}
}
Altri:






