Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/05/2005, 03:37
Avatar de caricatos
caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años, 1 mes
Puntos: 1284
Hola otra vez:

Había otro error al usar .src detrás de innerHTML

De todos modos, recuerdo que tenía algo hecho y te lo voy a enseñar, para ver si te sirve:

Código:
<html>
<head>
<title>
	4 imágenes sin repetir
</title>
<script>
var imagenes = [
	"http://www.sucaricatura.com/2002/maxi/2002H001.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H002.jpg",
	"http://www.sucaricatura.com/2002/maxi/2002H003.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H004.jpg",
	"http://www.sucaricatura.com/2002/maxi/2002H005.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H006.jpg",
	"http://www.sucaricatura.com/2002/maxi/2002H007.jpg"
];

var enlaces = [
	"http://www.sucaricatura.com/2002/mini/2002H001.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H002.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H003.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H004.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H005.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H006.jpg",
	"http://www.sucaricatura.com/2002/mini/2002H007.jpg"
];

function azar()	{
	var temp = new Array(4);
	temp[0] = Math.floor(Math.random() * imagenes.length);
	do
		temp[1] = Math.floor(Math.random() * imagenes.length);
	while (temp[0] == temp[1])
	do
		temp[2] = Math.floor(Math.random() * imagenes.length);
	while (temp[0] == temp[1] || temp[0] == temp[2] || temp[1] == temp[2])
	do
		temp[3] = Math.floor(Math.random() * imagenes.length);
	while (	temp[0] == temp[1] ||
		temp[0] == temp[2] ||
		temp[1] == temp[2] ||
		temp[0] == temp[3] ||
		temp[1] == temp[3] ||
		temp[2] == temp[3]
)
//	alert(document.links.length);
	document.getElementById("enlace1").setAttribute("href", enlaces[temp[0]]);
	document.getElementById("enlace2").href = enlaces[temp[1]];
	document.getElementById("enlace3").href = enlaces[temp[2]];
	document.getElementById("enlace4").href = enlaces[temp[3]];
	document.images.imagen1.src = imagenes[temp[0]];
	document.images.imagen2.src = imagenes[temp[1]];
	document.images.imagen3.src = imagenes[temp[2]];
	document.images.imagen4.src = imagenes[temp[3]];
	setTimeout("azar()", 5000)
}
</script>
</head>
<body onload=azar()>
<a href="#" name="enlace1">
<img src="" name=imagen1>
</a>
<a href="" name=enlace2>
<img src="" name=imagen2>
</a>
<a href="" name=enlace3>
<img src="" name=imagen3>
</a>
<a href="" name=enlace4>
<img src="" name=imagen4>
</a>
</body> 
</html>
El script original no tenía la rotación, pero es fácil añadirlo (el setTimeout)

Espero que te sirva.
Sobre el tema, puedes leer este mensaje: http://www.forosdelweb.com/showthread.php?t=169857

Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo

Última edición por caricatos; 14/05/2005 a las 03:47