Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Nill

Mudar imagens ao carregar pagina

Recommended Posts

Caros colegas, inserir uma imagem *.jpg, no topo da página, e esta imagem tem um link para abrir outra página, porém gostaria que toda a vez que um usuario entrasse na página essa imagem do topo, trocasse por outra automaticamente, exemplo: no topo de um imagem com o nome: SEGURA.JPG e esta imagem tem um link para a página SEGURA.HTM. E eu tenho outras imagens do mesmo tamanho e com links para outras páginas. Quando entrasse na pagina carregaria uma imagem com o seu link, quando entrasse em outra página ou pressionasse F5, essa imagem trocasse pela outra diferente com link para abrir outra página.Deu pra enteder?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Deixe-me ver se entendi:você tem um site, ate ai, beleza!ao entrar na pagina principal, no topo tem a imagem.principal.jpg (prefira gif se for desenho, fica mais leve) e dai, nessa imagem, teria um link p/ outra area do site, certo?beleza, entao o usuario clica nessa imagem e vai p/ a area desejada, so que, dentro dessa area desejada, teria no topo uma outra imagem, certo?Se você nao usa frames ou iframes, entao em cada pagina coloca a imagem referente seguido do link!ficando assim cada imagem:<img src="imagem1.gif><a href="pagina1.html></a>Ja p/ mudar usando o F5, teria que usar um codigo de mudança de arquivos, tenho dois tipos no meu site, na seção codigos!é por ai...[]sRodney

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, ai depende de que linguagem você está usando.Se for em ASP, eu tenho um codigo de randomização que você pode aplica facilmente ai no seu site, é só copiar, colar e alterar o SELECT (isso se os dados vem de um banco de dados). Se interessar eu posto aqui pra você ou mando por email.Claro que tem em outras linguagens tb, pergunte pro pessoal que você acha facinho. ;)

Compartilhar este post


Link para o post
Compartilhar em outros sites

Caros colegas, depois de muitas pesquisas conseguir desenvolver o script abaixo, testei é ele funcionou perfeitamente, a troca de imagens e feita quando carrega a página ou quando se preciona F5. O script segue abaixo:<head><script language="JavaScript">var how_many_ads = 3; // coloque aqui o número total de fotosvar now = new Date()var sec = now.getSeconds()var ad = sec % how_many_ads;ad +=1;if (ad==1) {foto="foto01.jpg"; // aqui você coloca a URL da foto1link="index.htm"; // link para abrir a página}if (ad==2) {foto="foto02.jpg"; // aqui você coloca a URL da foto2link="orcamento.htm"; // link para abrir a página}if (ad==3) {foto="foto03.jpg"; // aqui você coloca a URL da foto3link="mapa.htm"; // link para abrir a página}</script><script language="JavaScript">document.write('<a href="' + link +'">')document.write('<img src="'+ foto +'" border="0" />')</script></head>Qualquer duvida entre em contato

Compartilhar este post


Link para o post
Compartilhar em outros sites

Usei esse no meu site durante um tempo pra mostrar parceiros aleatórios, faz exatamente isso que você descreveu.

 

http://insider.desvio.com.br/random_link.htm

 

 

Código para escolher a imagem e o respectivo link:

<script LANGUAGE="JavaScript"><!-- This script and many more are available free online at --><!-- The JavaScript Source!! http://javascript.internet.com --><!-- Begin// Set up the image files to be used.var theImages = new Array() // do not change this// To add more image files, continue with the// pattern below, adding to the array.theImages[0] = '<a href="http://hyper.desvio.com.br"><img border="0" src="outros/hyper.jpg" width="88" height="31"></a>'theImages[1] = '<a href="http://nyan.desvio.com.br" target="_blank"><img border="0" src="outros/nyan.jpg" width="88" height="31"></a>'theImages[2] = '<a href="http://dreamit.kit.net/" target="_blank"><img border="0" src="outros/chris_dreamit.jpg" width="88" height="31"></a>'theImages[3] = '<a href="http://www.vbadesign.com/" target="_blank"><img border="0" src="outros/vba.gif" width="88" height="31"></a>'theImages[4] = '<a href="http://www.igorgrimaldi.com.br" target="_blank"><img border="0" src="outros/igorgrimaldi.jpg" width="88" height="31"></a>'theImages[5] = '<a href="http://www.delgadoweb.com.br/"><img border="0" src="outros/thiagalo-button.jpg" width="88" height="31"></a>'theImages[6] = '<a href="http://www.night.art.br/"><img border="0" src="outros/night.jpg" width="88" height="31"></a>'theImages[7] = '<a href="http://topi.draftmedia.com.br/"><img border="0" src="outros/topi.jpg" width="88" height="31"></a>'theImages[8] = '<a href="http://hyper.desvio.com.br"><img border="0" src="outros/hyper.jpg" width="88" height="31"></a>'theImages[9] = '<a href="http://www.noreason.kit.net/" target="_blank"><img border="0" src="outros/noreason_button.gif" width="88" height="31"></a>'theImages[10] = '<a href="http://www.cyber-tormentor.kit.net/" target="_blank"><img border="0" src="outros/logodiogo2.gif" width="88" height="31"></a>'theImages[11] = '<a href="http://heidertorres.upmasters.com" target="_blank"><img border="0" src="outros/banner_heider.jpg" width="88" height="31"></a>'theImages[12] = '<a href="http://www.sucramweb.com.br/" target="_blank"><img border="0" src="outros/banner_sucramdesign.gif" width="88" height="31"></a>'theImages[13] = '<a href="http://www.petitepoupeelayouts.blogger.com.br" target="_blank"><img border="0" src="outros/newbutonppl.gif" width="88" height="31"></a>'theImages[14] = '<a href="http://www.guilhermeloureiro.com/" target="_blank"><img border="0" src="outros/cyber.gif" width="88" height="31"></a>'theImages[15] = '<a href="http://www.good-tutorials.com" target="_blank"><img border="0" src="outros/good-tutorials.gif" width="88" height="31"></a>'theImages[16] = '<a href="http://www.photoshoplover.com" target="_blank"><img border="0" src="outros/pslbutton.gif" width="88" height="31"></a>'theImages[17] = '<a href="http://www.teamphotoshop.com" target="_blank"><img border="0" src="outros/team_ps.gif" width="88" height="31"></a>'theImages[18] = '<a href="http://www.deviantart.com" target="_blank"><img border="0" src="outros/deviantart.gif" width="88" height="31"></a>'theImages[19] = '<a href="http://forum.desvio.com.br" target="_blank"><img border="0" src="outros/db-forum.gif" width="88" height="31"></a>'theImages[20] = '<a href="http://www.sxc.hu" target="_blank"><img border="0" src="outros/sxc_main.gif" width="88" height="31"></a>'theImages[21] = '<a href="http://www.sloompy.com/" target="_blank"><img border="0" src="outros/sloompy.gif" width="88" height="31"></a>'theImages[22] = '<a href="http://www.vitordottori.com/" target="_blank"><img border="0" src="outros/vitordottori.jpg" width="88" height="31"></a>'theImages[23] = '</a><a href="http://www.edimassoli.com/" target="_blank"><img border="0" src="outros/edmassoli.gif" width="88" height="31"></a>'theImages[24] = '<a href="http://www.felipeneto.kit.net/" target="_blank"><img border="0" src="outros/felipe_neto.jpg" width="88" height="31"></a>'// do not edit anything below this linevar j = 0var p = theImages.length;var preBuffer = new Array()for (i = 0; i < p; i++){   preBuffer[i] = new Image()   preBuffer[i].src = theImages[i]}var whichImage = Math.round(Math.random()*(p-1));function showImage(){document.write('<table><tr><td>'+theImages[whichImage]+'</td></tr></table>');}//  End --></script>

E isso você coloca onde quer que a imagem com o link apareça:

<script LANGUAGE="JavaScript"><!-- This script and many more are available free online at --><!-- The JavaScript Source!! http://javascript.internet.com --><!-- BeginshowImage();//  End --></script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.