The innerText attribute can be used to obtain the text content of the current element after filtering out HTML Tags in the IE browser, which is quite useful in some cases. However, similar non-standard properties/methods are not necessarily supported in other browsers.
Similar ones like insertAdjacentElement , insertAdjacentElement , insertAdjacentHTML , insertAdjacentText etc. If you need to use these non-standard methods, or if the existing code uses these methods extensively, you must provide corresponding prototype definitions for other browsers. for example:
var isMinNS5 = (navigator.appName.indexOf("Netscape") >= 0 &&
parseFloat(navigator.appVersion) >= 5) ? 1 : 0;
if (isMinNS5){
HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode){
switch (where){
case beforeBegin:
This.parentNode.insertBefore(parsedNode,this)
break;
case afterBegin:
This.insertBefore(parsedNode,this.firstChild);
break;
case beforeEnd:
This.appendChild(parsedNode);
break;
case afterEnd:
if(this.nextSibling){
This.parentNode.insertBefore(parsedNode,this.nextSibling);
}
else{
this.parentNode.appendChild(parsedNode)
}
break;
}
}
HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr){
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.appendChild(parsedHTML)
}
HTMLElement.prototype.insertAdjacentText = function(where,txtStr){
var parsedText = document.createTextNode(txtStr)
this.insertAdjacentElement(where,parsedText)
}
HTMLElement.prototype.__defineGetter__
(
"innerText",
function(){
var anyString = "";
var childS = this.childNodes;
for(var i=0; i
anyString = childS[i].tagName=="BR" ? n : childS[i].innerText;
else if(childS[i].nodeType==3)
anyString = childS[i].nodeValue;
}
return anyString;
}
);
}