火狐报错 TypeError: oDiv is undefined

js代码如下:

window.onload = function Xiala() { var oNav = document.getElementById("nav"); var oLi = oNav.getElementsByTagName("li"); var i = 0; for (i = 0; i < oLi.length; i++) { oLi[i].onmouseover = function() { var oHeight = this.getElementsByTagName("div")[0].scrollHeight; this.className = "active"; shownav(this, oHeight); }; oLi[i].onmouseout = function() { this.className = " "; shownav(this, 0); }; }; }; function shownav(obj, n) { var oDiv = obj.getElementsByTagName("div")[0]; var aA = obj.getElementsByTagName("a"); clearInterval(obj.timer); obj.timer = setInterval(function() { if (n == oDiv.offsetHeight) { clearInterval(obj.timer); obj.timer = null; } else { var iHeight = (n - oDiv.offsetHeight) / 10; iHeight = iHeight > 0 ? Math.ceil(iHeight) : Math.floor(iHeight); oDiv.style.height = (oDiv.offsetHeight + iHeight) + "px"; } }, 5); <!--修改数字改变下拉速度--> }
<ul id="nav">
<li>
<a href="#">本网首页</a>
</li>
<li>
第一个
<div class="box div">
<a href="#">测试一下</a>
<a href="#">测试一下</a>
<a href="#">测试一下</a>
<a href="#">测试一下</a>
</div>
</li>
<li>
第二个
<div class="box">
<a href="#">测试一下</a>
<a href="#">测试一下</a>

</div>
</li>

<li>
<a href="#">第三个</a>
</li>
</ul>

TypeError: oDiv is undefined意思是错误类型:odiv是未定义的。

双语例句
  1  In fact, if you look at your WSDL file, the location addresses for the ports are undefined.
  事实上,如果查看WSDL文件,会发现未定义端口的位置地址。
  2  Reasonable accommodation is a squishy, undefined notion that varies based on the worker and employer 's situations and resources.
  适度调整是一个具有弹性空间、没有作出具体定义的概念,根据雇员的自身情况和雇主拥有的资源情况会有所不同。
  3  Specifies that the certificate has an undefined name constant.
  指定证书具有一个未定义的名称常数。
  4  When you load content from a URL, the default value is undefined until the load operation has started.
  从URL加载内容时,直到开始加载操作,才会定义默认值。
  5  Realization of undefined processing based on Java dynamic class loader
  基于Java动态类装载实现不确定性处理
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-08-12
getElementsByTagName("div")[0]好像直接这么用会报错也,ie下提示不是对象我记得,我一般都是用getElementBYId就不会报错了,要不就是找个出来tagname函数的来取出需要的对象本回答被提问者采纳
第2个回答  2014-08-12
  您好!很高兴为您答疑!

  错误的意思是:oDiv没有定义,如果请求的URL没有跨域,那很大可能就是代码写错了,检查下代码吧,AJAX百度下有很多。
  您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。本回答被网友采纳
相似回答