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?