function begin(drag){ 

    var x=event.clientX-parseInt(drag.style.left); 

    var y=event.clientY-parseInt(drag.style.top); 

    document.attachEvent("onmousemove",move); 

    document.attachEvent("onmouseup",getup) 

    function move(e){ 

        drag.style.left=(event.clientX-x)+"px"; 

        drag.style.top=(event.clientY-y)+"px"; 

    } 

    function getup(e){ 

        document.detachEvent("onmouseup",getup); 

        document.detachEvent("onmousemove",move); 

    } 

}

 posted on 2010-06-30 10:48  刘卿  阅读(199)  评论(0编辑  收藏  举报