var menuTimer =null;
function showmenu(obj1,obj2,state,location){
var btn=document.getElementById(obj1);
var obj=document.getElementById(obj2);
var h=btn.offsetHeight;
var w=btn.offsetWidth;
var x=btn.offsetLeft;
var y=btn.offsetTop;
obj.onmouseover =function(){
showmenu(obj1,obj2,'show',location);
}
obj.onmouseout =function(){
showmenu(obj1,obj2,'hide',location);
}
while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;}
var hh=obj.offsetHeight;
var ww=obj.offsetWidth;
var xx=obj.offsetLeft;//style.left;
var yy=obj.offsetTop;//style.top;
var obj2state=state.toLowerCase();
var obj2location=location.toLowerCase();
var showx,showy; if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"){
if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=ww-(x*0.7);showy=y;}
if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
if(obj2location=="bottom" || obj2location=="b"){showx=770;showy=20;}
}else{
showx=xx;showy=yy;
}
obj.style.left=showx+"px";
obj.style.top=showy+"px";
if(state =="hide"){
menuTimer =setTimeout("hiddenmenu('"+ obj2 +"')", 100);
}else{
clearTimeout(menuTimer);
obj.style.visibility ="visible";
}
}
function hiddenmenu(psObjId){
document.getElementById(psObjId).style.visibility ="hidden";
}
我的网页里有十个层,有的时候这代码不太灵敏,就是有时候鼠标离开链接的时候,之前弹出的层不隐藏。不知道该怎么处理。能否添加一些语句让鼠标接触链接的时候自动关闭之前弹出的层??
function showmenu(obj1,obj2,state,location){
var btn=document.getElementById(obj1);
var obj=document.getElementById(obj2);
var h=btn.offsetHeight;
var w=btn.offsetWidth;
var x=btn.offsetLeft;
var y=btn.offsetTop;
obj.onmouseover =function(){
showmenu(obj1,obj2,'show',location);
}
obj.onmouseout =function(){
showmenu(obj1,obj2,'hide',location);
}
while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;}
var hh=obj.offsetHeight;
var ww=obj.offsetWidth;
var xx=obj.offsetLeft;//style.left;
var yy=obj.offsetTop;//style.top;
var obj2state=state.toLowerCase();
var obj2location=location.toLowerCase();
var showx,showy; if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"){
if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=ww-(x*0.7);showy=y;}
if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
if(obj2location=="bottom" || obj2location=="b"){showx=770;showy=20;}
}else{
showx=xx;showy=yy;
}
obj.style.left=showx+"px";
obj.style.top=showy+"px";
if(state =="hide"){
menuTimer =setTimeout("hiddenmenu('"+ obj2 +"')", 100);
}else{
clearTimeout(menuTimer);
obj.style.visibility ="visible";
}
}
function hiddenmenu(psObjId){
document.getElementById(psObjId).style.visibility ="hidden";
}
我的网页里有十个层,有的时候这代码不太灵敏,就是有时候鼠标离开链接的时候,之前弹出的层不隐藏。不知道该怎么处理。能否添加一些语句让鼠标接触链接的时候自动关闭之前弹出的层??
解决方案 »
- 求解$.post(url,{},function(){});回调函数中如何使用判断语句
- request.getContextPath()与server.xml的context的path配置关系
- 如何得到第二个结果集
- 调用webservice,从tomcat移植到weblogic后报错
- TOMCAT5.5.X连接池的配置问题
- javaclub论坛招募“斑竹”(http://www.13u0.com)
- dreamweave中如何增加对jstl的支持?
- 有什么办法知道某个会话(session)已经终止了呢
- 在一个方法后面直接加上抛出异常和在该方法中捕捉异常有什么区别?
- mybatis输入映射控制台没有输出查询结果
- 急求高手解答!session.sava()一直无法往数据库中插入数据
- web多线程问题
if(divs.length>0){
for(var i=0;i<divs.length;i++){
if(divs[i].id != 你提供的那个ID)
{
divs[i].style.display = ""none;
}
}
} 是我现在手写的,如果有错误,你可以自己调一下