http://bt3.btchina.net表格是用 Sortable Table (http://webfx.eae.net/dhtml/sortabletable/demos.html)做的,可以点标题栏排序...将鼠标停留在“名称”列中某行时,出现一个类似Title的东西(DIV层),其中显示详细内容,鼠标可以移动到这个Title里面........
我只能做到让 div 隐藏或显示:
<script language="javascript">
function showdiv()
{
var mydiv=document.getElementById("div1");
mydiv.style.visibility="visible";
}
function hidddiv()
{
var mydiv=document.getElementById("div1");
mydiv.style.visibility="hidden";
}
</script><a href="http://www.163.com" onMouseOver="showdiv()" onMouseOut="hidddiv()">超级链接</a>
将鼠标移开,DIV就立即隐藏,鼠标始终移不到DIV上?我想作到:
1、鼠标能够移动到DIV区域内...
2、如果鼠标在DIV区域内,DIV始终显示...
哪位大哥给个完整点的代码啊?
谢谢!

解决方案 »

  1.   

    chinabh(黑鹰),谢谢!这个JS我已经有了,问题是:
    我想作到:
    1、鼠标能够移动到DIV区域内...
    2、如果鼠标在DIV区域内,DIV始终显示...
    3、DIV中如果有超链接的话,移动到它上面也不会消失...上面问题1、2已经解决,在DIV中再加onMouseOver和onMouseOut事件:
    <div id='dypopLayer' onMouseOver='showIt2()' onMouseOut='hiddIt2()'....></div>delay_out=null;  //定义一个新变量
    修改showPopupText()函数中的如下部分为:
    ......
    clearTimeout(tFadeWaiting);
    clearTimeout(delay_out);
    if(sPop==null || sPop=="") {
       delay_out=setTimeout("hiddIt2()",3000);   //修改的...
    }
    ......
    新加两个函数:
    function hiddIt2(){
    dypopLayer.innerHTML="";
    dypopLayer.style.filter="Alpha()";
    dypopLayer.filters.Alpha.opacity=0;
    }function showIt2(){
    clearTimeout(delay_out);
    dypopLayer.filters.Alpha.opacity=100;
    }但是问题3,还是没办法解决!-------------------------------------------------------------------------------------
    完整的HTML代码如下,复制后IE打开运行:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    //将title或alt转为Div标签
    tPopWait=50;
    tPopShow=5000;  //DIV延时消失时间
    showPopStep=20;
    popOpacity=100;sPop=null;
    curShow=null;
    tFadeOut=null;
    tFadeIn=null;
    tFadeWaiting=null;
    delay_out=null;document.write("<div id='dypopLayer' onMouseOver='showIt2()' onMouseOut='hiddIt2()' style='position:absolute;z-index:1000;background-color: #FFFFFF; border: 1px #CCCCCC solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)'></div>");function showPopupText(){
    var o=event.srcElement;  //触发事件的源对象
    MouseX=event.x;
    MouseY=event.y;
    if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
            if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
    if(o.dypop!=sPop) {
    sPop=o.dypop;
    clearTimeout(curShow);
    clearTimeout(tFadeOut);
    clearTimeout(tFadeIn);
    clearTimeout(tFadeWaiting);
    clearTimeout(delay_out);
    if(sPop==null || sPop=="") {
    delay_out=setTimeout("hiddIt2()",3000);
    }
    else {
    if(o.dyclass!=null) popStyle=o.dyclass 
    else popStyle="cPopText";
    curShow=setTimeout("showIt()",tPopWait);
    }

    }
    }function hiddIt2(){
    dypopLayer.innerHTML="";
    dypopLayer.style.filter="Alpha()";
    dypopLayer.filters.Alpha.opacity=0;
    }function showIt2(){
    clearTimeout(delay_out);
    dypopLayer.filters.Alpha.opacity=100;
    }function showIt(){
    dypopLayer.className=popStyle;
    dypopLayer.innerHTML=sPop;
    popWidth=dypopLayer.clientWidth;
    popHeight=dypopLayer.clientHeight;
    if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
    else popLeftAdjust=0;
    if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
    else popTopAdjust=0;
    dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
    dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
    dypopLayer.style.filter="Alpha(Opacity=0)";
    fadeOut();
    }
    //颜色渐强
    function fadeOut(){
    if(dypopLayer.filters.Alpha.opacity<popOpacity) {
    dypopLayer.filters.Alpha.opacity+=showPopStep;
    tFadeOut=setTimeout("fadeOut()",1);
    }
    else {
    dypopLayer.filters.Alpha.opacity=popOpacity;
    tFadeWaiting=setTimeout("fadeIn()",tPopShow);
    }
    }//颜色渐弱
    function fadeIn(){
    if(dypopLayer.filters.Alpha.opacity>0) {
    dypopLayer.filters.Alpha.opacity-=1;
    tFadeIn=setTimeout("fadeIn()",1);
    }
    }
    document.onmouseover=showPopupText;
    </script>
    </head><body>
    <p><a href="http://www.163.com" title="点击这里<br>第二行<br><a href='http://www.zj36.com' title=''>又一个连接</a>">测试,含超链接,鼠标移到DIV内的链接上就消失???</a></p>
    <p><a href="http://www.163.com" title="是飒飒 大一 <br>第撒成都市大扫除犯得上<br>第三行">测试测试测试2</a></p>
    </body>
    </html>
      

  2.   

    我的想法是--------------------------------------------------------------------------因为要屏蔽掉在DIV内的超链接对象,所以可以在showPopupText()中加入一个判断:
    var o=event.srcElement;  //触发事件的源对象
    判断:如果o的父一级的标签名称为‘div’,且id为‘dypopLayer’,则不进行任何操作...可是不知道用什么方法来获得?
    getEndTagEnders() ?
      

  3.   

    你去搜索导航菜单,
    关键在于两个div的区域要用重合的地方,然后你一移动,就可以进入菜单的div区域。否则永远也不可能有onMouseOver
      

  4.   

    div区域是可以进去了...只是:如果div内有<a>标签的话,移动到<a>上,整个div立即消失...因为用了:
    document.onmouseover=showPopupText;又再一次执行了showPopupText() 函数...可以复制我贴的代码,运行一下看看,就清楚了~谢谢!
      

  5.   

    我想对于div内的<a>标签的title、alt不进行转换....可以用鼠标位置来判断吗?
      

  6.   

    TO:chinabh(黑鹰) 非常谢谢您,我已经回复了您的邮件...具体问题都写在里面了我在ASP.NET版块中也问了这个问题:
    http://community.csdn.net/Expert/topic/4771/4771431.xml?temp=9.991091E-02
      

  7.   

    再顶顶,所有问题我都已记录下来:http://www.zj36.com/div_title.zip请下载后,帮忙看看,谢谢!
      

  8.   

    你还是到javascript版块问问吧...