兼容IE FF的getElementsByTagName方法

 1 View Code 
 2  // 兼容IE FF的getElementsByTagName方法
 3       var getElementsByName = function(tag, name){
 4           var returns = document.getElementsByName(name);
 5           if(returns.length > 0) return returns;
 6           returns = new Array();
 7           var e = document.getElementsByTagName(tag);
 8           for(var i = 0; i < e.length; i++){
 9               if(e[i].getAttribute("name") == name){
10                   returns[returns.length] = e[i];
11               }
12           }
13           return returns;
14       }
15  
16  getElementsByName("div", conName);
posted @ 2012-07-05 19:41  dtdxrk  阅读(661)  评论(0编辑  收藏  举报