作家
登录

msn上的tab功能Firefox对childNodes处理的一个BUG

作者: 来源:www.28hudong.com 2013-03-30 03:09:54 阅读 我要评论

Firefox对childNodes处理的一个BUG childNodesFirefox在处理childNodes没有过滤换行与空格。所以在初次使用的时候,得到效果不是预期的效果。 HTML 复制代码 代码如下: <ul class="tbtn" ID="menuList"> <li class="curr" id="tabap3_btn_0" onclick="tabit(this)">理财大学B</li> <li id="tabap3_btn_1" onclick="tabit(this)">名医讲堂</li> <li id="tabap3_btn_2" onclick="tabit(this)">名医讲堂</li> <li id="tabap3_btn_3" onclick="tabit(this)">名医讲堂</li> <li class="lst" id="tabap3_btn_4" onclick="tabit(this)">影坛热点</li> </ul> JS 复制代码 代码如下: function tabit(btn) { var idname = new String(btn.id); var s = idname.indexOf("_"); var e = idname.lastIndexOf("_")+1; var tabName = idname.substr(0, s); var id = parseInt(idname.substr(e, 1)); var tabNumber = btn.parentNode.childNodes.length; //IE和FF的值不同 for(i=0;i<tabNumber;i++) { if(document.getElementById(tabName+"_div_"+i)!=null) //这里需要进行判断 { document.getElementById(tabName+"_div_"+i).style.display = "none"; document.getElementById(tabName+"_btn_"+i).style.backgroundImage = "url(pic/t-1-2.gif)"; document.getElementById(tabName+"_btn_"+i).style.borderBottomColor = "#D7F2DA"; document.getElementById(tabName+"_btn_"+i).style.cursor = "pointer"; } } document.getElementById(tabName+"_div_"+id).style.display = "block"; btn.style.backgroundColor = "#fff"; btn.style.borderBottomColor = "#fff"; btn.style.cursor = "default"; } 在IE上menuList的childNodes.length的值为5,而在Firefox值为11.因此我们在使用childNodes对象时需要先对其判断或去掉空格。

  推荐阅读

  window.addeventjs事件驱动函数集合addEvent等

// written by Dean Edwards, 2005 // with input from Tino Zijdel, Matthias Miller, Diego Perini // http://dean.edwards.name/weblog/2005/10/add-event/ function addEvent(element, type, handler) { if >>>详细阅读


本文标题:msn上的tab功能Firefox对childNodes处理的一个BUG

地址:http://www.17bianji.com/kaifa2/JS/29838.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)