Hola a todos. Tengo una web en la que he creado una secuencia de imágenes en html. El problema es que no sé como poner en el código un enlace distinto a otra web para cada una de las imágenes. MI objetivo final es poder mapear cada una de esas imágenes a varios enlaces, pero prefiero ir poco a poco.
Mi web es www.servigali.es y el código que he insertado es:
<html>
<head>
<script type="text/javascript">
function rotarImagenes(idDestino, imagenInicial){
this.SecuenciaID=null;
this.imagen=imagenInicial;
this.duracion=2000;
this.imagenes="";
this.listadoImagenes="";
this.showId=idDestino;
this.CreaArray=function(n) {
this.length = n
for (var i = 0; i<n; i++) {
this[i] = new Image()
}
return this
};
this.Secuencia=function(type) {
if(type=="stop")
{
clearTimeout(this.SecuenciaID);
}else if(type=="start"){
this.MostrarSecuencia();
}
};
this.MostrarSecuencia=function() {
document.getElementById(this.showId).src = this.imagenes[this.imagen].src;
this.imagen++;
if(this.imagen>=this.listadoImagenes.length)
this.imagen=0
var instant = this;
this.SecuenciaID=setTimeout(function() { instant.MostrarSecuencia();}, this.duracion);
};
this.IniciarSecuencia=function(listadoImagenes) {
this.listadoImagenes=listadoImagenes;
this.imagenes=new this.CreaArray(listadoImagenes.length);
for (var i = 0; i<listadoImagenes.length; i++) {
this.imagenes[i].src = listadoImagenes[i];
}
this.MostrarSecuencia();
};
};
var img1=new rotarImagenes("secuencia1",0);
var listadoImagenes1=[
'http://servigali.es/wp-content/uploads/2015/09/Conjunto1-1.png',
'http://servigali.es/wp-content/uploads/2015/09/Conjunto1-2.png',
'http://servigali.es/wp-content/uploads/2015/09/Conjunto1-3.png',
'http://servigali.es/wp-content/uploads/2015/09/Conjunto1-4.png'
];
function start_rotarImagenes()
{
img1.IniciarSecuencia(listadoImagenes1);
}
</script>
</head>
<body onload="start_rotarImagenes()">
Publicidad:<p>
<img src="" alt="Secuencia" id="secuencia1">
</p>
</body>
</html>
Es un código que encontré ya que yo no sé mucho de programación. Si creéis que sería mejor otro también vale. Gracias.