Ir para conteúdo
Fórum Script Brasil
  • 0

Mudando Plano De Fundo Por Um Button


Steffan

Pergunta

Aew, minha dúvida é a seguinte:

quero mudar o plano de fundo da minha página através de um botão

vai ter um botão e quando clicar nele vai ativar a função

mudar_bg()

alguém faz pra mim um script em java script para executar essa ação de mudar o papel de parede atual para outro ?

algo como

<script language="Javascript">
<!--
function mudar_bg()
window.background('http://www.site.com.br/bg_novo.jpg')
//-->
</script>

E aproveitando o tópico para postar outra dúvida. Como mudo a cor da seta de um select?

O select padrão do IE é azul com a seta preta. Quero um select com a seta branca e no lugar do azul o preto.

vlw

Link para o comentário
Compartilhar em outros sites

10 respostass a esta questão

Posts Recomendados

  • 0

Não. Eu to chamando a função dentro da própria página. A função é chamada por outra função. Veja o código da minha página:

<HTML>
<HEAD>
<TITLE>Grupo C.R.O.W.</TITLE>
</HEAD>
<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgColor="black" onload="loadcomplete()">//aqui eu chama a função loadcomplete
<style type="text/css">
<!--
BODY {
fixed;
overflow: hidden;}
body{
background-color:000000;
background-image:url('imagens/load.gif');//aqui eu escolho a imagem que carrega desde o inicio
background-attachment: fixed;
background-position:center;
background-repeat:no-repeat;
}
.submenu{
MARGIN-BOTTOM: 0.3em;
}
//-->
</style>

<script language="Javascript">
<!--
window.status=("www.grupocrow.oi.com.br");
function loadcomplete(){//funcao loadcomplete aqui, ela chama a funcao mostrarpagina()
SwitchMenu('100pct');
setTimeout("mostrarpagina()",1600)}
function mostrarpagina(){//funcao mostrar pagina que chama outra funcao, a mudar_bg()
SwitchMenu('frames');
setTimeout("mudar_bg()",1000)}
function mudar_bg(){//funcao mudar_bg, que não está funcionando
document.body.background=("imagens/bg.gif");
}
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu")
ar[i].style.display = "none";}
el.style.display = "block";}
else{el.style.display = "none";}}}
function mudar_bg(){
document.body.background = 'http://www.grupocrow.com.br/imagens/bg.jpg';
}
//-->
</script>

<DIV id=masterdiv>
<SPAN class=submenu id=100pct>
<TABLE height="100%" width="100%" align=center summary="">
  <TBODY>
  <TR>
    <tudo vAlign=center align=middle>
<img src="imagens/100pct.gif" galleryimg="no">
</tudo></TR></TBODY></TABLE>
</SPAN>
<SPAN class=submenu id=frames>
<TABLE height="100%" width="100%" align=center summary="">
  <TBODY>
  <TR>
    <tudo vAlign=center align=middle>
<div style="position:center;width:513px;height:393px;">
<iframe name="frames" src="frames.html" frameborder="0" width="513" height="393" scrolling="no"
allowtransparency="false"></iframe></div>
</tudo></TR></TBODY></TABLE>
</SPAN>
</DIV>
</BODY>
</HTML>

Link para o comentário
Compartilhar em outros sites

  • 0

OpA! Eu vi que coloquei a função mudar_bg() duas vezes. apaguei a de baixo, mas mesmo assim não funcionou.

Vou dar uma explicada:

A função mudar_bg() é chamada pela função mostrarpagina(). A função mostrarpagina() é chamada pela funcao loadcomplete() que é chamada no BODY por onload.

function loadcomplete(){

SwitchMenu('100pct');

setTimeout("mostrarpagina()",1600)

}

function mostrarpagina{

SwitchMenu('frames');

setTimeout("mudar_bg()",1000)

}

function mudar_bg{

document.body.background="imagens/bg.gif";

}

Eu acho que o style está atrapalhando...

Link para o comentário
Compartilhar em outros sites

  • 0

não deu certo;

vamos começar uma pagina do zero.

<HTML><HEAD></HEAD>

<BODY onload="mudar_bg()">

<style type="text/css">

body{

background-color:000000;

background-image:url('http://www.grupocrow.oi.com.br/imagens/load.gif');

background-attachment: fixed;

background-position:center;

background-repeat:no-repeat;

}

</style>

<script language="Javascript">

function mudar_bg(){

//O que fazer para mudar o background da página?

//Observe que o background não está definido na tag body e sim dentro do style

//Essa função não pode alterar os outros atributos como fixed, center, no-repeat, 000000.

}

</script>

</BODY>

</HTML>

Já tentei as seguintes funções:

function mudar_bg(){

//document.write('<style type="text/css"> \n')

//document.write('body { \n')

//document.write('background-color:000000; \n')

//document.write('background-image:url("http://www.grupocrow.oi.com.br/imagens/bg.png"); \n')

//document.write('background-attachment: fixed; \n')

//document.write('background-position:center; \n')

//document.write('background-repeat:no-repeat; } \n')

//document.write('</style> \n')

}

function mudar_bg(){

//document.body.background = 'http://www.grupocrow.oi.com.br/imagens/bg.png';

}

NENHUMA funciona!

Link para o comentário
Compartilhar em outros sites

  • 0

acabei de tentar esta:

function mudar_bg(){

document.write('<style type="text/css">\n')

document.write('body{background-color:000000; background-image:url("imagens/bg.png");background-attachment: fixed; background-position:center; background-repeat:no-repeat;}\n')

document.write('<style>\n')

}

mas deu erro.

Link para o comentário
Compartilhar em outros sites

  • 0

CONSEGUIIIIIIIIIIIIIIIIIIIIIIIIIII

Finalmente!

Veja como é:

acrescente o seguinte dentro do body:

<BODY onload="mudar_bg()" id="bg">

Olhe a função como é:

function mudar_bg(){

document.getElementById('bg').style.background='#000000 url(imagens/bg.png) center center no-repeat';

}

UFA!!!!!!

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...