terça-feira, 22 de novembro de 2011

Piscando texto, imagem div, etc... com javascript

Veja abaixo uma função que criamos para fazer piscar um elemento da página. Pode usar com texto, imagem, tabela, div, etc...


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function piscando(){
               
                //Autor: Bruno Passos - Clandevelop Sistemas e Sites
                //http://www.clandevelop-sistemas-e-sites.blogspot.com
               
                var tempo = 500; //1000 = 1s      
               
                blinks = document.getElementsByTagName("blink");    
                for(var i=0;i<blinks.length;i++){
                                if(blinks[i].getAttribute("style")=="VISIBILITY: hidden"){                              
                                                blinks[i].setAttribute("style", "VISIBILITY: visible");                         
                                }else{                   
                                                blinks[i].setAttribute("style", "VISIBILITY: hidden");                       
                                }
                }                             
                setTimeout('piscando()', tempo);            
}
</script>
</head>
<body onload="piscando();"> 

  <blink><a href="http://www.cineclan.com.br">Cineclan - Novidades do Cinema</a></blink>
  <br />

  <blink>
  <div>Piscando o Div</div>
  </blik> 

  <br /> 

  <blink> 
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>Piscando</td>     
    </tr>
    <tr>
      <td>Tabela</td>    
    </tr>
  </table>
  </blink> 
</body>
</html>

Um comentário: