分享

FireFox支持innerText

 西门独孤 2011-02-14
  1. <script language="javascript">  
  2. function isIE(){ //ie?   
  3. if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1)   
  4.     return true;   
  5. else   
  6.     return false;   
  7. }   
  8.  
  9. if(!isIE()){ //firefox innerText define  
  10.     HTMLElement.prototype.__defineGetter__("innerText",   
  11.     function(){  
  12.         var anyString = "";  
  13.         var childS = this.childNodes;  
  14.         for(var i=0; i<childS.length; i++) {   
  15. Webjx.Com  
  16.  
  17.  
  18.             if(childS[i].nodeType==1)  
  19.                 //anyString += childS[i].tagName=="BR" ? "\n" : childS[i].innerText;  
  20.                 anyString += childS[i].innerText;  
  21.             else if(childS[i].nodeType==3)  
  22.                 anyString += childS[i].nodeValue;  
  23.         }  
  24.         return anyString;  
  25.     }   
  26.     );   
  27.     HTMLElement.prototype.__defineSetter__("innerText",   
  28.     function(sText){  
  29.         this.textContent=sText;   
  30. Webjx.Com  
  31.  
  32.     }   
  33.     );   
  34. }  
  35. </script>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多