Possible Duplicate:
regular expression gives different output in FF and IE
I use following code
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;
}
var queuediv = document.getElementById('MSO_ContentTable');
var total = get_text(queuediv);
countTotal = total.split(/\s+/).length;
alert(countTotal);
the div contains text:-
You can get started fdfd erfd dsff
the code gives me output:-26
Note:- Chrome and Fx gives output 7 but IE gives 26. I think the problem is in the regular expression. This regex is not working in IE I think
Well regular expressions aren’t actually standardized and some tools do use \+ instead of + for the greedy version of the quantifier. You could try that in IE and see what the results are and then have conditional code to make it work in IE (imagine that).