IE支持GetElementsByClassname

if (navigator.appName == 'Microsoft Internet Explorer') {   
        document.getElementsByClassName = function() {   
            var tTagName = "*";   
            if (arguments.length > 1) {   
                tTagName = arguments[1];   
            }   
            if (arguments.length > 2) {   
                var pObj = arguments[2]   
            } else {   
                var pObj = document;   
            }   
            var objArr = pObj.getElementsByTagName(tTagName);   
            var tRObj = new Array();   
            for ( var i = 0; i < objArr.length; i++) {   
                if (objArr[i].className == arguments[0]) {   
                    tRObj.push(objArr[i]);   
                }   
            }   
            return tRObj;   
        }   
    }  

  

posted @ 2011-10-26 22:27  心的开始  阅读(1750)  评论(1编辑  收藏  举报