0x800a138f - JavaScript 运行时错误: 无法获取未定义或 null 引用的属性,怎么办? 5
在ie下调试,报出:0x800a138f-JavaScript运行时错误:无法获取未定义或null引用的属性<scriptlanguage="javascript">fu...
在ie下调试,报出:0x800a138f - JavaScript 运行时错误: 无法获取未定义或 null 引用的属性
<script language="javascript">
function initializeMenu(menuName) {
var menu= document.getElementsByName(menuName);
var k,i,len,tablelen;
for ( k=0,tablelen=menu.length; k <tablelen; k++)
{
var actuator=menu[k];
actuator.onclick = function() {
var display = this.nextSibling.nextSibling.style.display;
if (display == "none")
this.nextSibling.nextSibling.style.display = "block";
else
this.nextSibling.nextSibling.style.display = "none";
return false;}
}
}
function showcategory(menuID)
{
var menu=document.getElementById(menuID);
//menu.className="";
while (menu.parentElement.id!="MenuRoot")
{
if (menu.tagName=="UL" && menu.style.display=='none')
{
menu.style.display="block";
//menu.className="";
}
menu=menu.parentElement;
}
}
window.onload = function() {
initializeMenu("menuname");
}
</script>
<div id="MenuRoot">
<ul>
<ul>
<li><a href="#" name="menuname" id="1">第一级菜单</a>
<ul style="display:none">
<li><a href="#" >第二级菜单3</a></li>
<li><a href="#">第二级菜单4</a></li>
<li><a href="#">第二级菜单5</a></li>
</ul>
</li>
<li><a href="" name="menuname" title="" id="2">Flashlights</a>
<ul style="display:none">
<li><a href="">Rechargeable Flashlights</a></li>
<li><a href="" >LED Flashlights & Sets</a></li>
</ul>
</li>
</ul>
</ul>
</div>
<script>showcategory("2");</script> 展开
<script language="javascript">
function initializeMenu(menuName) {
var menu= document.getElementsByName(menuName);
var k,i,len,tablelen;
for ( k=0,tablelen=menu.length; k <tablelen; k++)
{
var actuator=menu[k];
actuator.onclick = function() {
var display = this.nextSibling.nextSibling.style.display;
if (display == "none")
this.nextSibling.nextSibling.style.display = "block";
else
this.nextSibling.nextSibling.style.display = "none";
return false;}
}
}
function showcategory(menuID)
{
var menu=document.getElementById(menuID);
//menu.className="";
while (menu.parentElement.id!="MenuRoot")
{
if (menu.tagName=="UL" && menu.style.display=='none')
{
menu.style.display="block";
//menu.className="";
}
menu=menu.parentElement;
}
}
window.onload = function() {
initializeMenu("menuname");
}
</script>
<div id="MenuRoot">
<ul>
<ul>
<li><a href="#" name="menuname" id="1">第一级菜单</a>
<ul style="display:none">
<li><a href="#" >第二级菜单3</a></li>
<li><a href="#">第二级菜单4</a></li>
<li><a href="#">第二级菜单5</a></li>
</ul>
</li>
<li><a href="" name="menuname" title="" id="2">Flashlights</a>
<ul style="display:none">
<li><a href="">Rechargeable Flashlights</a></li>
<li><a href="" >LED Flashlights & Sets</a></li>
</ul>
</li>
</ul>
</ul>
</div>
<script>showcategory("2");</script> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询