Der Internet Explorer 8 hat mit der Javascript Eigenschaft textContent so seine Probleme. Es kommt ein undefined heraus wenn man diese Eigenschaft im Internet Explorer 8 abfragt. Eli Grey hat für dieses Problem eine schöne Lösung gefunden:
if (Object.defineProperty && Object.getOwnPropertyDescriptor && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get)
(function() {
var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText");
Object.defineProperty(Element.prototype, "textContent",
{ // It won't work if you just drop in innerText.get
// and innerText.set or the whole descriptor.
get : function() {
return innerText.get.call(this)
},
set : function(x) {
return innerText.set.call(this, x)
}
}
);
})();
Diese Funktion fügt man dabei in eine extra Javascript Datei ein und bindet sich dann per Browserweiche ein:
<!--[if gte IE 8]><script type="text/javascript" src="textContent.js"></script><![endif]-->
Anschließend kann man die textContent Eigenschaft normal benutzen.
Weitere Informationen gibt es unter:
http://eligrey.com/blog/post/textcontent-in-ie8