My problem is that when I use this code:
var queuediv = document.getElementById('MSO_ContentTable');
var total = get_text(queuediv);
countTotal = total.split(/\s+/).length;
this is the function
function get_text(el) {
ret = "";
var length = el.childNodes.length;
for (var i = 0; i < length; i++) {
var node = el.childNodes[i];
if (node.nodeType != 8) {
ret += node.nodeType != 1 ? node.nodeValue : get_text(node);
}
}
return ret;
}
it gives me different values in IE and other browser gives same value. So is there a problem with my regexp?
Thanks.
You are splitting by white space characters (line breaks, tabs ...). These seems to vary in DOM representation of different browsers. I assume you are trying to split words. Try:
or
you may replace
\v
and\t
also.