js css 做的二级菜单,ie调试下有错误,求检查下谢谢

varcssdropdown={disappeardelay:250,disablemenuclick:false,enableswipe:1,enableiframes... var cssdropdown={
disappeardelay: 250,
disablemenuclick: false,
enableswipe: 1,
enableiframeshim: 1,
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,
getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},
swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){“-------这是19行
this.bottomclip+=5+(this.bottomclip/5)
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 5)
},
showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)"
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},
iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},
clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure)
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},
......
上面是js代码,每个一级导航连接ID对应一个二级菜单Ul的ID,鼠标放到没有二级菜单的连接上就会出现js错误,提示问题在19行,怎么修改一下呢?
弄这个太费劲了http://zhidao.baidu.com/question/548836919?quesup2&oldq=1,这个要能解决才是关键
展开
 我来答
百度网友a19d193
2013-05-09 · TA获得超过3446个赞
知道大有可为答主
回答量:1464
采纳率:100%
帮助的人:1416万
展开全部
代码太长了哈,没仔细去看。
你既然说了鼠标放到没有二级菜单的连接上就会出现js错误,那么就是说此时一级导航连接ID没有对应的二级菜单ul的id咯?如果没有html元素被选中,你去取它的offset当然就错了。所以你可以先判断一下是不是有二级菜单,如果没有就可以直接return了,是吧?

或者尝试一下
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight))
变成
if (this.dropmenuobj && this.bottomclip<parseInt(this.dropmenuobj.offsetHeight))

另外,根据这个错误我觉得你的html代码布局可能有问题。这个只是纯建议,也没有采纳必要。
我觉得不应该出现没有二级菜单ul的情况。意思是二级菜单可以只有0个菜单项,但是不应该没有放置二级菜单的容器。
追问
对,是那个意思,不过那代码没管用,呵呵
追答
哈,我也没期待它能管用。如果你的代码加亮了还好,这样看太费劲了。我的意见就是你先判断有没有可供显示的二级菜单,如果没有的话干脆连swipeeffect这个方法都不调用。

别的可能帮不到你咯,努力调试一下吧。
百度网友08a61832
2013-05-09 · TA获得超过739个赞
知道小有建树答主
回答量:178
采纳率:100%
帮助的人:81.7万
展开全部
一个二级菜单居然能写得如此复杂。。佩服。。!!!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
风云真岚
2013-05-09 · 超过39用户采纳过TA的回答
知道小有建树答主
回答量:101
采纳率:0%
帮助的人:99.8万
展开全部
什么错误?
追问
就是js调用二级菜单ID的时候,没有对应ID的,鼠标放上就提示,脚本错误,本地调试的,不能上网址啊
追答
我是问错误的内容,用debug查看的话应该可以看到具体错误的
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式