function getText(m){
var strings = [];
getString(m, strings);
return strings.join(" ");
function getString(m, strings){
if(m.nodeType == 3){
strings.push(m.data);
}else if(m.nodeType == 1){
for(t = m.firstChild; t != null; t = t.nextSibling){
getString(t, strings);
}
}
}
}<body onload="getText(${body });"  >
This is a <i>simple</i> example.</body>