Jump to content
Fórum Script Brasil
  • 0

Imagens Alternadas com Mapeamento e Link


Question

Uma ajuda por favor, tenho um codigo em javascript que alterna as imagens de exibição e queria incluir nele se possivel um mapeamento da imagem para direcionar para varios links, sendo que cada imagem tem um mapeamento com links diferentes, se não for possivel favor me mandarem algum codigo em php pois acho que aissim e possivel.

Por exemplo uma figura divida em 4x4 com quatro links, depois exiba outra figura divida em 4x4 com outros quatro links.

Deu p/ enter?

<script language="JavaScript">

<!--

function random_imglink(){

var myimages=new Array()

myimages[0]="images/home_random_01.jpg";

myimages[1]="images/home_random_02.jpg";

myimages[2]="images/home_random_03.jpg"

myimages[3]="images/home_random_04.gif"

myimages[4]="images/home_random_05.gif"

myimages[5]="images/home_random_06.gif"

myimages[6]="images/home_random_07.gif"

myimages[7]="images/home_random_08.gif"

myimages[8]="images/home_random_09.gif"

/*myimages[4]="images/home_random_05.gif"*/

pic1= new Image()

pic1.src = myimages[0]

pic2= new Image()

pic2.src = myimages[1]

pic3= new Image()

pic3.src = myimages[2]

pic4= new Image()

pic4.src = myimages[3]

pic5= new Image()

pic5.src = myimages[4]

pic5= new Image()

pic5.src = myimages[5]

pic5= new Image()

pic5.src = myimages[6]

pic5= new Image()

pic5.src = myimages[7]

pic5= new Image()

pic5.src = myimages[8]

var rndimg=Math.floor(Math.random()*myimages.length);

document.images.randimage.src = myimages[rndimg];

setTimeout('random_imglink()',3000)

}

//-->

</script>

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Opa, fiz um exemplo aqui.

Vê se você entende.

<html>
<head>
<title>Mudando Link</title>
<script type="text/javascript">
function mudaLink(type) {
var ahref = document.getElementById("a_href");
if(type == 0) {
    ahref.href = "http://www.oi.com.br";
} else {
    ahref.href = "http://www.claro.com.br";
}
}
</script>
</head>
<body>
<input type="button" value="Mudar link 0" onclick="mudaLink(0)">
<br />
<input type="button" value="Mudar link 1" onclick="mudaLink(1)">
<br /> <br />
<a id="a_href" href="http://www.terra.com.br">Link</a>
</body>
</html>

Abraços.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148691
    • Total Posts
      644531
×
×
  • Create New...