Ver Mensaje Individual
  #4 (permalink)  
Antiguo 04/09/2013, 14:38
bathorz
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 10 años, 8 meses
Puntos: 29
Respuesta: Añadir enlace JS en HTML

/ruta era una carpeta que estaba en lugar de /Imagenes.
No llama a las imágenes 2 veces. La función imprime tantas etiquetas <a> como registros haya en el array. Lee sobre funciones y bucles.
Código HTML:
Ver original
  1.    <head>
  2.       <script language="JavaScript">
  3.          var fotos = new Array();
  4.          fotos = [["Imagenes/Azul1.jpg", "http://www.google.es/"], ["Imagenes/Blanco2.jpg", "http://www.youtube.com/"]];
  5.  
  6.          function fotos(string) {
  7.             for (var i = 0; i < fotos.length; i++) {
  8.               document.write("<a href='" + fotos[i][1] + "'><img id='misfotos' src='" + fotos[i][0] + "' /></a>");
  9.                document.write("<br>");
  10.             };
  11.          }
  12.       </script>
  13.    </head>
  14.    <body>
  15.       <script language="JavaScript">
  16.          fotos();
  17.       </script>
  18.    </body>
  19. </html>