您好,今天是: ·加入收藏·设为首页·联系站长
洛歌教程网--本站提供(PS教程)
站内搜索:
当前位置:洛歌教程网 >> 网站建设 >> JavaScript技术应用 >> 浏览文章  
FireFox支持innerText
作者:admin 来源:网络 文章点击数:
document.write(document.body.textContent);

对于习惯使用innerText的人来说有点不舒服,于是网上有人就给FireFox也创建了一个innerText属性,代码如下:

<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>



默认FireFox是不支持innerText的,不过它有一个属性textContent的作用和innerText是一样的,使用方法如下:



人支持

发表评论】【告诉好友】【打印此文】【收藏此文】【关闭窗口
  最新文章
  热门文章
  推荐文章

| 设为首页 | 加入收藏 | 关于本站 | 联系站长 | 友情链接 | 版权申明 | 雁过留声 |

Copyright◎ 2003-2007 www.logooe.com All Rights Reserved Contact us

Email:liyushuai755#163.com QQ:65557616

版权归作者所有,如果无意中侵犯了您的版权,请来信告知,本站将再3个工作日内删除。

备案序号:琼ICP备06003564号

 


Free

本站(洛歌教程网)提供如下信息:PS教程,PhotoShop教程,SoftImage 3D教程,AutoCAD教程,maya教程,3ds max教程,平面设计欣赏,ImageReady教程,Illustrator教程,Coreldraw教程,Flash教程,freehand教程,fireworks教程,图像辅助