JavaScript - secuencia de imágenes con link

 
Vista:
sin imagen de perfil

secuencia de imágenes con link

Publicado por juanfrangm (2 intervenciones) el 27/09/2015 17:41:11
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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<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()">
 
&nbsp;&nbsp;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.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder