打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
火狐兼容innerText 方法
(function (bool) {
    
function setInnerText(o, s) {
        
while (o.childNodes.length != 0) {
            o.removeChild(o.childNodes[
0]);
        }

        o.appendChild(document.createTextNode(s));
    }

    
function getInnerText(o) {
        
var sRet = "";

        
for (var i = 0; i < o.childNodes.length; i ++) {
            
if (o.childNodes[i].childNodes.length != 0) {
                sRet 
+= getInnerText(o.childNodes[i]);
            }

            
if (o.childNodes[i].nodeValue) {
                
if (o.currentStyle.display == "block") {
                    sRet 
+= o.childNodes[i].nodeValue + "\n";
                } 
else {
                    sRet 
+= o.childNodes[i].nodeValue;
                }
            }
        }

        
return sRet;
    }

    
if (bool) {
        HTMLElement.prototype.__defineGetter__(
"currentStyle"function () {
            
return this.ownerDocument.defaultView.getComputedStyle(thisnull);
        });//FF IE 获取样式兼容

        HTMLElement.prototype.__defineGetter__(
"innerText"function () {
            
return getInnerText(this);
        })

        HTMLElement.prototype.__defineSetter__(
"innerText"function(s) {
            setInnerText(
this, s);
        })
    }
})(
/Firefox/.test(window.navigator.userAgent));
</script>

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
struct加Ajax
*javascript 节点nodeName,nodeValue,nodeType,childNodes,removeChile,appendChild
DrawingManager.js
javascript窗口淡入淡出效果和读取xml
一直寻求一套最好的OOL Object-Oriented-Layer
dede:sql实现分页
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服