//
Code:
function getComments(hoo){
if(!arguments.length) hoo=document;
var A= [];
if(hoo){
hoo= hoo.firstChild;
while(hoo!= null){
if(hoo.nodeType== 8){
A[A.length]= hoo.data;
}
else A= A.concat(arguments.callee(hoo));
hoo= hoo.nextSibling;
}
}
return A;
}
// Test
alert(getComments())
Note- IE (only) will return doctype text, if the page has a doctype, as the first item in the array. You can ignore it or remove it before the return -
Code:
if(A[0].toLowerCase().indexOf('doctype')==0)A.shift();
return A;