Eis o código:
<STYLE> A.linkrotator:link { text-decoration: none; color: black; font-weight: bold; } A.linkrotator:visited { text-decoration: none; color: black; font-weight: bold; } A.linkrotator:active { text-decoration: none; color: black; font-weight: bold; } A.linkrotator:hover { text-decoration: none; color: orange; font-weight: bold; } </STYLE> <script> function grabElement( sId ) { if(document.getElementById) { return document.getElementById(sId); } else { if(document.all) { return document.all[sId]; } else { return document.layers[sId]; } } } var numLinks = posCorrente = -1; var timer = 5; // tempo default (em segundos) var links = new Array(); linkRotator = new Object(); linkRotator.create = createLinkRotator; linkRotator.add = addLinkRorator; linkRotator.setTimer = setTimerLinkRotator; linkRotator.init = initLinkRotator; function createLinkRotator() { document.write("<DIV ID='linkRotator'> </DIV>"); } function addLinkRorator( sText, sURL ) { links[++numLinks] = new Array( sText, sURL ); } function setTimerLinkRotator( sTimer ) { timer = sTimer; } function initLinkRotator() { linkUpdate(); } function linkUpdate() { if(++posCorrente == numLinks+1) { posCorrente = 0; } grabElement('linkRotator').innerHTML = "<A CLASS='linkrotator' HREF='"+ links[posCorrente][1]+"'>"+ links[posCorrente][0] +"</A>"; setTimer(); } function setTimer() { window.setTimeout("linkUpdate()", timer*1000); } </SCRIPT>
As definições CSS usadas já estão inclusas, para alterá-las, simplesmente edite as tags.
Para usar é bem simples... basta que você coloque o código abaixo no local onde quer executar o link rotator.
<script> linkRotator.create(); linkRotator.setTimer(3); linkRotator.add("Cade", "http://www.cade.com.br"); linkRotator.add("Yahoo", "http://www.yahoo.com.br"); linkRotator.add("Teste2 (Interno)", "teste2.html"); linkRotator.add("Página em branco", "about:blank"); linkRotator.init(); </SCRIPT>
Da mesma forma que o banner rotator, o método add adiciona um novo item no link rotator... mas o número máximo de argumentos é 2 (texto e link), e todos os links abrirão na janela corrente. Os outros métodos controlam a inicialização, criação e setagem de tempo entre as alternâncias dos textos.
Caso alguém tenha dúvida, entre em contato comigo...
[]s,