黑妞与白胖
愿得一人心,白首不相离!
 
<html>
<title></title>
  <script type="text/javascript">
        function Drag(obj)
        {
            var obj = document.getElementById(obj);
            obj.style.position = "absolute";
            obj.onmousedown = function(e)
            {
                e = e || window.event;
                var x = e.offsetX;
                var y = e.offsetY;
                document.onmousemove = function(e)
                {
                    e = e || window.event;
                    obj.style.left = (e.clientX - x) + "px";
                    obj.style.top = (e.clientY - y) + "px";
                }
                document.onmouseup = function()
                {
                    document.onmousemove = null;
                    obj.onmousedown = null;
                }
            }
        }
    </script>
</head>
<body>
    <div id="div"  style="background-color:White;width:300px;height:250px;">
     <div id="p" style="cursor:move;background-color:Red;width:300px;height:25px;" onmousedown="Drag('div')">        
     </div>
     <div>
     正文  
     </div>
    </div>
</body>
</html>
posted on 2012-11-06 15:55  慢阳阳  阅读(210)  评论(0编辑  收藏  举报