这个是我模仿做的一个鼠标放上去显示详细的一个js程序
效果如下:http://www.dalianfang.com/jsdemo/default6.html
代码查看源文件可见
现在有两个问题
1)我鼠标放上去有抖动的效果,也就是说,我把鼠标放在弹出层上,底下层的onmousever事件也被触发了
2)想做一个弹出的详细层的时候有一个过渡的效果
http://community.csdn.net/Expert/topic/5571/5571620.xml?temp=5.099124E-02谁帮着解决对了200分重谢!

解决方案 »

  1.   

    <SCRIPT type=text/javascript>
    /*set position */
    function getposOffset(over_forshow, offsettype){
    var totaloffset=(offsettype=="left")? over_forshow.offsetLeft : over_forshow.offsetTop;
    //totaloffset根据参数取得距离左边或上边的高度距离
    var parentEl=over_forshow.offsetParent;
    //offsetParent 属性指定的父坐标的高度或长度
    //offsetTop 指 obj 距离上方或上层控件的位置,整型,单位像素
    //obj.offsetLeft 指 obj 距离左方或上层控件的位置,整型,单位像素。//obj.offsetWidth 指 obj 控件自身的宽度,整型,单位像素。//obj.offsetHeight 指 obj 控件自身的高度,整型,单位像素。while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft: totaloffset+parentEl.offsetTop;
    //如果是x,left,左边的位置+
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }/*on mouse over event  */function over_forshow(curobj, subobjstr){
    if (document.getElementById){
    var subobj=document.getElementById(subobjstr)
    var subobj2=document.getElementsByTagName(subobjstr)
    var s = "block";
    closeall();
    subobj.style.display=(subobj.style.display!="block")? "block" : "none"
    var xpos=getposOffset(curobj, "left")-(subobj.offsetWidth-curobj.offsetWidth);
    var ypos=getposOffset(curobj, "top")+curobj.offsetHeight
    subobj.style.left=xpos+"px"
    subobj.style.top=170+"px"//you can resize the num to adjust the  position
    //alert(xpos)
    subobj.style.zindex=9;
    curobj.style.zindex=5;return false
    }
    else
    return true
    }function over_forshowclose(subobj){
    document.getElementById(subobj).style.display="none"
    }/*close all the layer  of the details*/
    function closeall(){  for(i=1;i<=4;i++)   //replace the num"4" to your num(itmes counts)  
      {
     document.getElementById("showdetails"+i).style.display="none"
      }
      }
    </SCRIPT>
      

  2.   

    <SCRIPT type=text/javascript>
    /*set position */
    function getposOffset(over_forshow, offsettype){
    var totaloffset=(offsettype=="left")? over_forshow.offsetLeft : over_forshow.offsetTop;
    //totaloffset根据参数取得距离左边或上边的高度距离
    var parentEl=over_forshow.offsetParent;
    //offsetParent 属性指定的父坐标的高度或长度
    //offsetTop 指 obj 距离上方或上层控件的位置,整型,单位像素
    //obj.offsetLeft 指 obj 距离左方或上层控件的位置,整型,单位像素。//obj.offsetWidth 指 obj 控件自身的宽度,整型,单位像素。//obj.offsetHeight 指 obj 控件自身的高度,整型,单位像素。while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft: totaloffset+parentEl.offsetTop;
    //如果是x,left,左边的位置+
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }/*on mouse over event  */function over_forshow(curobj, subobjstr){
    if (document.getElementById){
    var subobj=document.getElementById(subobjstr)
    var subobj2=document.getElementsByTagName(subobjstr)
    var s = "block";
    closeall();
    subobj.style.display=(subobj.style.display!="block")? "block" : "none"
    var xpos=getposOffset(curobj, "left")-(subobj.offsetWidth-curobj.offsetWidth);
    var ypos=getposOffset(curobj, "top")+curobj.offsetHeight
    subobj.style.left=xpos+"px"
    subobj.style.top=170+"px"//you can resize the num to adjust the  position
    //alert(xpos)
    subobj.style.zindex=9;
    curobj.style.zindex=5;return false
    }
    else
    return true
    }function over_forshowclose(subobj){
    document.getElementById(subobj).style.display="none"
    }/*close all the layer  of the details*/
    function closeall(){  for(i=1;i<=4;i++)   //replace the num"4" to your num(itmes counts)  
      {
     document.getElementById("showdetails"+i).style.display="none"
      }
      }
    </SCRIPT>
      

  3.   

    onmouseover的时候
    如果要显示那个是display=""就返回
    否则就display=""
      

  4.   

    动态添加onmousever不就解决了吗?
    上面的层出现的时候移除下面层的onmousever
    element.detachEvent("onmousever",functionName);
    上面的层消失的时候再加回来
    element.attachEvent("onmousever",functionName);
      

  5.   

    楼上的wangwei0406 没明白你说的意思,能给个具体的例子吗