日期:2014-05-16  浏览次数:20390 次

JavaScript制作滑动门,FireFox和IE下都正确显示

<script type="text/javascript" defer="defer">
??? 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";
??? }
</script>

<ul>
??? <li class="curr" id="tab1_btn_0" onmouseover="tabit(this)">新闻</li>
??? <li id="tab1_btn_1" onmouseover="tabit(this)">图片</li>
??? <li id="tab1_btn_2" onmouseover="tabit(this)">影视</li>
??? <li id="tab1_btn_3" onmouseover="tabit(this)">FLASH</li>
</ul>
</tr>
<div id="tab1_div_0">
新闻列表信息
</div>
<div id="tab1_div_1" style="display:none;">
图片列表信息
</div>
<div id="tab1_div_2" style="display:none;">
影视列表信息
</div>
<div id="tab1_div_3" style="display:none;">
FLASH列表信息
</div>