FireFox支持innerText的方法

 1 function isIE(){ //ie? 
 2 if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
 3     return true; 
 4 else 
 5     return false; 
 6 } 
 7 
 8 if(!isIE()){ //firefox innerText define
 9     HTMLElement.prototype.__defineGetter__("innerText", 
10     function(){
11         var anyString = "";
12         var childS = this.childNodes;
13         for(var i=0; i<childS.length; i++) { 
14             if(childS[i].nodeType==1)
15                 //anyString += childS[i].tagName=="BR" ? "\n" : childS[i].innerText;
16                 anyString += childS[i].innerText;
17             else if(childS[i].nodeType==3)
18                 anyString += childS[i].nodeValue;
19         }
20         return anyString;
21     } 
22     ); 
23     HTMLElement.prototype.__defineSetter__("innerText", 
24     function(sText){
25         this.textContent=sText; 
26     } 
27     ); 
28 }
原文地址:https://www.cnblogs.com/dtdxrk/p/2782782.html