Edit
Included filter to not get content of certain elements
They are two different properties - one is defined in the W3C DOM 3 Core, the other is a Microsoft proprietary property that has been widely copied but has no open specification.
Probably the best way to normalise the two is to not use them, instead use a DOM-walking routine that collects text nodes and creates a string. Use the same routine for both (all) browsers.
// Get the text within an element
// Doesn't do any normalising, returns a string
// of text as found.
function getText(element) {
var text = [];
var self = arguments.callee;
var el, els = element.childNodes;
var excluded = {
'noscript': 'noscript',
'script' : 'script'
};
for (var i=0, iLen=els.length; i<iLen; i++) {
el = els[i];
// May need to add other node types here
if ( el.nodeType == 1 &&
!(el.tagName.toLowerCase() in excluded)) {
text.push(self(el));
// If working with XML, add nodeType 4 to get text from CDATA nodes
} else if (el.nodeType == 3) {
// Deal with extra whitespace and returns in text here.
text.push(el.data);
}
}
return text.join('');
}