Ver Mensaje Individual
  #3 (permalink)  
Antiguo 06/05/2010, 08:48
tomato
 
Fecha de Ingreso: mayo-2010
Mensajes: 3
Antigüedad: 13 años, 11 meses
Puntos: 0
Respuesta: Fondo de tabla con imagen aleatoria

Gracias Emprear, pero no hay forma de hacer funcionar el script que propones:
Evidentemente algo estoy haciendo mal o estoy colocandolo donde no corresponde. Te pido por favor alguna pista adicional.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fondo aleatorio</title>
</head>

<body>
<div align="center">
<script language="javascript">
<!--
onload = function() {
/* Aqui va el directorio donde estan las imagenes. */
var imageDirectory = "http://www.midominio.com/fondo/";
/* Para agregar mas imagenes asegurese de incluirlas en la lista considerando las comillas y la coma al final de cada linea. */
var imageArray = new Array("galeria3.jpg",
"galeria2.jpg",
"galeria1.jpg",
"galeria4.jpg",
"galeria0.jpg",
"galeria5.jpg");
var imageArrayLength = imageArray.length;// No modifique las lineas siguientes
var pseudoRandomNumber = ( Math.round( Math.random() * (imageArrayLength - 1) ) );
document.getElementById("tableImage").style.backgr oundImage="url('" +
"imageDirectory + imageArray[pseudoRandomNumber] + "')";
}
//-->
</script>
<noscript>
<style type="text/css">
#tableImage {
background-image:url('http://www.midominio.com/fondo/galeria3.jpg');
}
</style>
</noscript>
</div>
<table width="980" border="0" cellpadding="0" cellspacing="0" id="tableImage">
<tr>
<td height="580">&nbsp;</td>
</tr>
</table>
</body>
</html>