Tema: pinche for
Ver Mensaje Individual
  #9 (permalink)  
Antiguo 07/11/2011, 20:32
Avatar de Carlangueitor
Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: pinche for

A ver esto:
Código HTML:
Ver original
  1. <!DOCTYPE HTML>
  2. <html lang="es-MX">
  3.     <meta charset="UTF-8">
  4.     <title>Prueba Enlaces</title>
  5. </head>
  6.     <a href="http://www.test.com">1</a>
  7.     <a href="http://www.test.com">2</a>
  8.     <a href="http://www.test.com">3</a>
  9.     <a href="http://www.test.com">4</a>
  10.     <a href="http://www.test.com">5</a>
  11.    
  12.     <script type="text/javascript">
  13.         var numero = 0;
  14.         for(i=0;i<document.links.length;i++){
  15.             b = document.links[i].href;
  16.             c = b.slice(0,15);
  17.             if(c.toString() == "http://www.test"){
  18.                 numero++;
  19.                 }
  20.             }
  21.         alert(numero);
  22.     </script>
  23. </body>
  24. </html>

Creo que el problema es cómo estás comparando las cadenas.

Saludos
__________________
Grupo Telegram Docker en Español