Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/05/2006, 05:55
Avatar de wesse
wesse
 
Fecha de Ingreso: junio-2003
Ubicación: España
Mensajes: 577
Antigüedad: 21 años, 9 meses
Puntos: 1
caricatos muchas gracias, pero tengo un pequeño problema, y es que no puedo poner <body onload...> ya que esto irá en un include php sin etiquetas html.. como podría cambiar eso?

Código HTML:
<script >
var datos = function(imagen, enlace, alt) {
	this.imagen = imagen;
	this.enlace = enlace;
	this.alt = alt;
}
var objetos = new Array();
objetos[0] = new datos("http://www.google.es/images/hp1.gif", "http://www.google.es", "ir a google");
objetos[1] = new datos("http://www.lycos.es/test/i/global_logo.gif", "http://www.lycos.es", "ir a lycos");
objetos[2] = new datos("http://www.terra.es/ivi/por/img/terra.gif", "http://www.terra.es", "ir a terra");
function aleatorio() {
	var azar = Math.floor(Math.random() * objetos.length);
	document.images["imagen"].src = objetos[azar].imagen;
	document.getElementById("enlace").href = objetos[azar].enlace;
}
</script>

<body onload="aleatorio()">
     <a href="#" name="enlace" id="enlace">
	     <img src="" name="imagen" />
     </a> 
PD: cómo hago para sacar los alt que he insertado?