By default, FireFox does not support innerText, but it has the same function as innerText in textContent. The usage is as follows:
Document. write (document. body. textContent );
It is a little uncomfortable for people who are used to using innerText, so someone on the Internet also created an innerText attribute for FireFox. The Code is 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 ",
Function (){
Var anyString = "";
Var childS = this. childNodes;
For (var I = 0; I <childS. length; I ++ ){
Webpage tutorial Network
If (childS [I]. nodeType = 1)
// AnyString + = childS [I]. tagName = "BR "? "\ N": childS [I]. innerText;
AnyString + = childS [I]. innerText;
Else if (childS [I]. nodeType = 3)
AnyString + = childS [I]. nodeValue;
}
Return anyString;
}
);
HTMLElement. prototype. _ defineSetter _ ("innerText ",
Function (sText ){
This. textContent = sText; Webjx. Com
}
);
}
</Script>