Jump to content


Photo

Problema Com Slideshow No Ie


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 Fábio Morato

Fábio Morato

    Novato no fórum

  • Usuários
  • 6 posts
  • Sexo:Masculino
  • Localidade:Pitangui

Posted 24/07/2012, 14:48

Olá pessoal, estou com um pequeno problema com um slideshow que eu fiz em Javascript, funciona corretamente no Chrome, Firefox e Opera, porém não funciona com o Internet Explorer...
Código:
function imagem(img){
  var imagem = new Image();
  myimg = imagem.src = img;
  return myimg;
}

var sid = 1;
var mudaslideshow;
var imgs = new Array();
imgs[1] = imagem("/img/html.png"); imgs[2] = imagem("/img/css.png"); imgs[3] = imagem("/img/php.png");
var selecionado = new Array();
selecionado[1] = "slide1"; selecionado[2] = "slide2"; selecionado[3] = "slide3";

function comecaSlide(){
  mudaslideshow = setInterval("slideshow()", 5000);
  slideshow();
}
function slideshow(){
  document.getElementById("slideshow").src=imgs[sid];
  colocabg(sid);
  if(sid!=3)
    sid+=1;  
  else
    sid=1;
}
function mudaslide(id){ // para o menu do slideshow
  sid = id;
  if(id==1){
    tirabg(2); 
    tirabg(3);   
  }
  else if(id==2){
    tirabg(1); 
    tirabg(3);
  }
  else if(id==3){
    tirabg(1); 
    tirabg(2);
  }
  clearInterval(mudaslideshow);
  slideshow();
  mudaslideshow = setInterval("slideshow()", 5000);
}
function colocabg(id){ // para o menu do slideshow
  document.getElementById(selecionado[id]).style.background="rgba(0, 0, 0, 0.2)";
  if(id==1)
    tirabg(3)
  else if(id==2)
    tirabg(1);
  else if(id==3)
    tirabg(2);
}
function tirabg(id){ // para o menu do slideshow
  document.getElementById(selecionado[id]).style.background="rgba(0, 0, 0, 0.1)";
}
E é claro, comecaSlide() é chamado:
<body onload="comecaSlide()">...</body>

Alguém sabe por quê não funciona? =\

EDIT...

Pode deixar, descobri o erro! O erro nem está nesse código, porque fiz algumas adaptações (para diferentes navegadores) nele...
Só tive que mudar tirabg() e colocabg(), que davam o erro "Argumento inválido."
Pra quem quiser ver:

function colocabg(id){
  <?php 
    if(!detectaIE())
        echo '  document.getElementById(selecionado[id]).style.background="rgba(0, 0, 0, 0.2)";';
    else
        echo '  document.getElementById(selecionado[id]).style.background="url(\'/webfacil/img/slideshow_ie_bg2.png\') repeat";';
  ?>

  if(id==1){
    tirabg(2); 
    tirabg(3);   
  }
  else if(id==2){
    tirabg(1); 
    tirabg(3);
  }
  else if(id==3){
    tirabg(1); 
    tirabg(2);
  }
}
function tirabg(id){
<?php 
  if(!detectaIE())
    echo 'document.getElementById(selecionado[id]).style.background="rgba(0, 0, 0, 0.1)";';
  else
    echo 'document.getElementById(selecionado[id]).style.background="url(\'/webfacil/img/slideshow_ie_bg.png\') repeat";';
?>
}

Edição feita por: Fábio Morato, 24/07/2012, 14:49.





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq