日期:2014-05-18  浏览次数:21128 次

如何能像windows桌面上的图标拖动一样的效果?
如何做到像windows桌面上的图标拖动一样的效果?大家帮帮忙

------解决方案--------------------
div噻,简单
------解决方案--------------------
<html>
<body>

<style id= "css ">
body{font-family:Verdana;font-size:11px;color:#333;}
#win1{[position:absolute;left:100;top:100;width:200px;height:150px;border:1px solid #000;}
.title{width:100%;background:#000;height:18px;color:#fff;cursor:hand;}
</style>

<script>
var move=false;
function StartDrag(obj)
{
if(event.button==1&&event.srcElement.tagName.toUpperCase()== "DIV ")
{
obj.setCapture();
obj.style.background= "#999 ";
move=true;
}
}

function Drag(obj)
{
if(move)
{
var oldwin=obj.parentNode;
oldwin.style.left=event.clientX-50;
oldwin.style.top=event.clientY-10;
}

}

function StopDrag(obj)
{
obj.style.background= "#000 ";
obj.releaseCapture();
move=false;
}

</script> <div id= "win1 ">
<div class= "title " onMousedown= "StartDrag(this) " onMouseup= "StopDrag(this) " onMousemove= "Drag(this) " > 窗口1 </div>
This is a moveable window. <br>
Moreinfo in www.achome.cn .
</div>

</body>
</html>
试试
------解决方案--------------------
bucuo