http://community.csdn.net/Expert/topic/4761/4761096.xml?temp=.8734552

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4760/4760928.xml?temp=.2667658
    看看吧,我实在没办法了
      

  2.   

    不太好做啊,只好判断鼠标的位置是不是在span的上方,如果在就调变色的函数
    <script>
    <!--
    function setCookie(top,left)
    {
        document.cookie="top="+top;
        document.cookie="left="+left;
    }
    function getCookie(name)
    {
        var mycookie=document.cookie;
        var start=mycookie.indexOf(name+"=");
        if (start!=-1) 
        {
            start=mycookie.indexOf("=",start)+1;
            var end=mycookie.indexOf(";",start);
            if (end==-1)
            end=mycookie.length;
            var value=unescape(mycookie.substring(start,end));
            if (value!=null) 
            {
                var obj=document.getElementById("TheDiv");
                if (name=="top")
                obj.style.top=value;
                if (name="left")
                obj.style.left=value;
            }
        }
    }
    function moveobj(obj)
    {
        var x=event.clientX;
        var y=event.clientY;
        obj.setCapture();
        function obj.onmousemove()
        {
            if(obj)
            {
                var nx=event.clientX;
                var ny=event.clientY;
                window.status="X="+nx+"Y="+ny;
                obj.style.posLeft+=nx-x;
                obj.style.posTop+=ny-y;
                x=nx;
                y=ny;
            }
            var spanObj=document.getElementById("span1")
            if((event.x>spanObj.style.left)&&(event.x<(spanObj.style.left+spanObj.clientWidth)))
            {
             if((event.y>spanObj.style.top)&&(event.x<(spanObj.style.top+spanObj.clientHeight)))
             {
             setspan()
             }
            }
        }
        function obj.onmouseup()
        {
            var stop=0;
            obj.releaseCapture();
            var nowtop=obj.style.top;
            var nowleft=obj.style.left;
            setCookie(nowtop,nowleft);
            obj=false;
        }
    }
    function setspan()
    {
        span1.style.background="red";
    }
    //-->
    </SCRIPT>
    <div id="TheDiv" onmousedown="moveobj(this)" style=" float:left; position:absolute;width:200px;height:200px;background:#355ddd;border:1px #356999 solid;cursor:move; z-index:0;"></div>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <span id="span1" style="width:100px;height:100px;background:#355ddd; z-index:1;" onmouseover="setspan();">sjdfkdsjfkdfj</span>
      

  3.   

    我也想到了用鼠标和span的位置来做,但是我用的是backbase的drag-drop,没有办法获取鼠标,所以......
    不管怎样,还是非常感谢了!!!