可实现任意拖动,有标题栏功能 var moveFlag = 0;//拖曳是否开始(0:否,1:是) var mouseBeginX = 0;//鼠标的起始x座标 var mouseBeginY = 0;//鼠标的起始y座标 var modeBeginTop = 0;//拖曳对象当前的top值 var modeBeginLeft = 0;//拖曳对象当前的left值 /// 鼠标按下事件 function selectBegin(e){ move Flag = 1; e.setCapture()
代码如下: function offsetTop( elements ){ var top = elements.offsetTop; var parent = elements.offsetParent; while( parent != null ){ top += parent.offsetTop; parent = parent.offsetParent; }; return top; }; function offsetLeft( elements ){ var left = elem