Ver Mensaje Individual
  #15 (permalink)  
Antiguo 10/05/2013, 07:11
Anarko
 
Fecha de Ingreso: febrero-2004
Mensajes: 1.987
Antigüedad: 20 años, 2 meses
Puntos: 22
Respuesta: TRUCASO para capturar este innerHTML: <!-- <div id="fin">datos y + datos..

Cita:
Iniciado por Panino5001 Ver Mensaje
Creí que sobreentenderías que para recorrer el DOM el mismo debía estar cargado.
Agradezco tu ayuda, te comento que no captura lo que posiciono luego de la etiqueta </html> que es lo que debo lograr.
Código:
<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8" /> 
<title></title> 
<!-- hola -->
<script type="text/javascript"> 
function htmlTree(obj){ 
    var str = ""; 
    if (obj.hasChildNodes()) { 
      var child = obj.firstChild; 
      while (child) { 
          if (child.nodeType === 8) { 
               str +=child.nodeValue + '\n'; 
          } 
        if (child.nodeType === 1) { 
          str += htmlTree(child); 
        } 
        child = child.nextSibling; 
      } 
    } 
    
    return str; 
  } 
  
    
onload=function(){alert(htmlTree(document.documentElement));}; 
</script> 
</head>
<body> 
</body> 
</html>
<!-- chau -->
Efectivamente no comprendo ni tu código ni el
Código:
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", document.URL, true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
source = xmlhttp.responseText;
var a = source.split('id="uno" ');
alert(a[1]);
var b = a[1].split(' -->');
alert('el contenido del comentario es: ' + b[0]);
}
}
xmlhttp.send(null)
que logra capturar TODO, pero yo debo elegir solo UNO de esos comentarios...

Efectivamente sería prefereible para mí correr el código desde la misma pagina y no llamando la función desde un archivo externo, pero creo que no se puede...