Como você bem notou, hoje eu adicionei a função de site:
Select background ![]()
Este recurso foi escrito por mim em javascript.
Mas como isso funciona?
Em essência, este recurso é habilitado quando a caixa de seleção está marcada e modificado o css, e no meu caso o fundo ![]()
Este é o princípio:
document.styleSheets[0].cssRules[0].style.background="IMMAGINE "; Onde:
document.styleSheets [0]: CSS é a nossa (primeira);
Espero que possa ser útil ![]()
Fonte:
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"; } }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"; } }
Outros:






