By default, Firefox does not support innertext, but it has the same function as innertext in textcontent. The procedure is as follows: program code document. Write (document. Body. textcontent );
It is a little uncomfortable for people who are used to using innertext, so someone on the Internet also creates an innertext attribute for Firefox. The Code is as follows: program code <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 ++ ){
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;
}
);
}
</SCRIPT>