随笔 - 8  文章 - 55  trackbacks - 0
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

朋友的Blog

最新评论

阅读排行榜

评论排行榜

让getElementsByName适应IE和firefox
w3c规范中getElementsByName是按着name属性进行检索的,而MS的IE却是按着id来检索。导致不能得到应该得到的Elements,为适应浏览器,我们可以做一下调整:
一、把需要用getElementsByName的name都加上id,且id和name相同。
二、用一个函数来适应浏览器,代码如下:
getElementsByName:function (name) {
              var 
returns document.getElementsByName(name);
              if(
returns.length 0) return returns;
              
returns = new Array();
              var 
document.getElementsByTagName('td');
              for(
0e.lengthi++) {
                            if(
e[i].getAttribute("name") == name) {
                                          
returns[returns.length] = e[i];
                            }
              }
              return 
returns;
}
posted on 2006-10-08 11:20 blog搬家了--[www.ialway.com/blog] 阅读(594) 评论(0)  编辑  收藏 所属分类: PHP

只有注册用户登录后才能发表评论。


网站导航: