< div id = " divMove " style = " POSITION: absolute;left:300;top:300 " onselectstart = " return false " onmousedown = " MouseDown(this) " onmousemove = " MouseMove() " > < table width = " 150 " cellpadding = " 0 " cellspacing = " 0 " border = " 1 " > < tr > < td height = " 30 " bgcolor = " #cccccc " > title </ td > </ tr > < tr > < td height = " 100 " >< p align = " center " > testMove </ p ></ td > </ tr > </ table > </ div > < SCRIPT LANGUAGE = " JavaScript " > <!-- var currentMoveObj = null ; var relLeft,relTop; function MouseDown(obj) { currentMoveObj = obj; currentMoveObj.style.position = " absolute " ; relLeft = event.x - currentMoveObj.style.pixelLeft; relTop = event.y - currentMoveObj.style.pixelTop; } window.document.onmouseup = function () { currentMoveObj = null ; } function MouseMove() { if (currentMoveObj != null ) { currentMoveObj.style.pixelLeft = event.x - relLeft; currentMoveObj.style.pixelTop = event.y - relTop; } } // --> </ SCRIPT > 转载于:https://www.cnblogs.com/Elong/archive/2005/04/17/139236.html