`
y1d2y3xyz
  • 浏览: 252522 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

extjs源码分析-005(Ext.getDom,Ext.getBody)

阅读更多
var DOC = document;
//获取DOM节点对象
getDom : function(el, strict){//el-->id 或者 html节点,strict-->是否只支持ID属性(ie下IE的name属性也能获取)获取节点对象
            if(!el || !DOC){
                return null;
            }
            if (el.dom){
                return el.dom;
            } else {
                if (typeof el == 'string') {//如果传的参数是字符串,就当是ID处理
                    var e = DOC.getElementById(el);
                    // IE returns elements with the 'name' and 'id' attribute.
                    // we do a strict check to return the element with only the id attribute
                    if (e && isIE && strict) {
                        if (el == e.getAttribute('id')) {
                            return e;
                        } else {
                            return null;
                        }
                    }
                    return e;
                } else {
                    return el;
                }
            }
        },

getBody : function(){//获取文档的body节点对象
     return Ext.get(DOC.body || DOC.documentElement);
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics