Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/09/2009, 05:13
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 17 años
Puntos: 574
Respuesta: cambiar imagen dentro de una tabla al cargar

Código html:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <title>Documento sin t&iacute;tulo</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4. <SCRIPT language="JavaScript">
  5.  
  6. <!-- Begin JS Script -->
  7.  
  8. <!-- Begin
  9. // Set up the image files to be used.
  10. var theImages = new Array() // do not change this
  11. // To add more image files, continue with the
  12. // pattern below, adding to the array.
  13.  
  14. theImages[0] = 'img1.jpg'
  15. theImages[1] = 'img2.jpg'
  16. theImages[2] = 'img3.jpg'
  17. theImages[3] = 'img4.jpg'
  18. theImages[4] = 'img5.jpg'
  19.  
  20.  
  21.  
  22. // do not edit anything below this line
  23.  
  24. var j = 0
  25. var p = theImages.length;
  26. var preBuffer = new Array()
  27. for (i = 0; i < p; i++){
  28. preBuffer[i] = new Image()
  29. preBuffer[i].src = theImages[i]
  30. }
  31. var whichImage = Math.round(Math.random()*(p-1));
  32. function showImage(){
  33. document.getElementById('laimagen').src=theImages[whichImage];
  34. }
  35.  
  36. // End -->
  37. </head>
  38.  
  39. <body onLoad="showImage()">
  40. <table width="100%" border="1" cellspacing="0" cellpadding="0">
  41.   <tr>
  42.     <td align="center" valign="middle"><img src="img1.jpg" id="laimagen"></td>
  43.   </tr>
  44.  
  45. </body>
  46. </html>

funciona?

Quim

Edito: Adler se me ha adelantado, esta seria otra opción...