Categorias:

Traduzir:
Italiano flagInglese flagFrancese flagTedesco flagPortoghese flagSpagnolo flag

[Javascript] background Selecione

Como você bem notou, hoje eu adicionei a função de site:

Select background : P

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 : P

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:

  1. JavaScript: Zoom sobre o texto (fonte maior)
  2. Adicionar: Artigo WordPress Preview
  3. Vancouver 2010: GAME PC
  4. Encerramento Compiler: otimiza seu javascript =)
  5. mysql login script PHP com cookies
Você pode deixar uma resposta , ou trackback de seu próprio site.

One Response to "[Javascript] fundo Select"

    Trackback e pingback

    1. [Javascript] background Selecione
      [...] Lendo a fonte deste artigo: [Javascript] background Selecione Artigos relacionados: [PHP / MySQL] Erro de MySQL em Salvar arquivo ...

    Adicionar um comentário