火狐下对js 的innertext支持不好,如果直接使用的话,它给你的是一个undefined,我也遇到了这个问题,解决办法如下:

JavaScript代码
//from jeccy's blog  
<script language="javascript">  
function isIE(){ //ie?   
window.alert('JECCY's BLOG');  
   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;  
      else if(childS[i].nodeType==3)  
       anyString += childS[i].nodeValue;  
     }  
     return anyString;  
    }   
   );   
   HTMLElement.prototype.__defineSetter__(     "innerText",   
    function(sText){   
     this.textContent=sText;   
    }   
   );   
}  
</script>

随机日志