Get text method in IE innertext not supported in Firefox
Firefox changed to Textcontent method/attribute
And the whitespace in the middle of the Firefox Chinese text is replaced by a ruthless replacement.
It's extremely inconvenient to use.
Now it's okay to redefine the InnerText method with JavaScript.
So you can also use the InnerText method in Firefox
And this method solves the problem of the white space character in Firefox
How to use:
Put the following script inside the page
Both IE and Firefox can use Obj.innertext to extract text.
Copy Code code as follows:
<script language= "javascript" >
function Isie () {//ie?
if (Window.navigator.userAgent.toLowerCase (). IndexOf ("MSIE") >=1)
return true;
Else
return false;
}
if (!isie ()) {//firefox innertext define
htmlelement.prototype.__definegetter__ ("innertext",
Funct Ion () {
var anystring = ';
var childS = this.childnodes;
for (var i=0 i<childs.length; i++) {
if (childs[i].nodetype==1)
AnyString = childs[i].tagname== "br"? ' \ n ': childs[i].textcontent;
Else if (childs[i].nodetype==3)
AnyString + = Childs[i].nodevalue;
}
Return anystring;
}
);
htmlelement.prototype.__definesetter__ ("innertext",
Function (stext) {
This.textcontent=stext;
}
);
}
</script>