解决浏览器兼容改内容的函数

解决浏览器兼容改内容的函数 ,区分IE与非IE内核

function intext(name, value) {
            //如何区别IE和非IE, IE的document中有all这个属性
            if(document.all) {
                if(typeof(value)=="undefined") {
                    return name.innerText;
                }else {
                    name.innerText=value;
                }
            }else{
                if(typeof(value)=="undefined") {
                    return name.textContent;
                }else {
                    name.textContent = value;
                }    
            }
        }
//都兼容的写法

var aobj = document.getElementById("xdl");
aobj.innerHTML = "<h1>IT峰播</h1>";
原文地址:https://www.cnblogs.com/wicrecend/p/5422876.html