各位兄弟,我onmousedown的时候取得一个对象,然后移动对象div,移到指定的对象上面,做onmouseup动作,放在移到的指定对象上面不动
onmousedown的时候肯定可以获得对象,可是当onmouseup的时候,我怎么获得当前鼠标下对应的对象。
我现在能做到移动时不拖动down时获得的对象,那么up时就能得到当前鼠标下的对象
可是移动时拖动对象,那么就无法取得任何对象了。因为鼠标下的对象是移动的那个对象,怎么能透过移动的div,获得鼠标当前对象
请大家帮帮忙
onmousedown的时候肯定可以获得对象,可是当onmouseup的时候,我怎么获得当前鼠标下对应的对象。
我现在能做到移动时不拖动down时获得的对象,那么up时就能得到当前鼠标下的对象
可是移动时拖动对象,那么就无法取得任何对象了。因为鼠标下的对象是移动的那个对象,怎么能透过移动的div,获得鼠标当前对象
请大家帮帮忙
<HTML><HEAD>
<BODY>表格中拖动单元格改变顺序 Gu Laicheng 2009-02-04 22:54
<SCRIPT language=javascript>
var beginMoving=false;
function MDTM(obj){
obj.style.zIndex=1;
obj.mouseDownY=event.clientY;
obj.mouseDownX=event.clientX;
beginMoving=true;
obj.setCapture();
}function MMTM(obj){
if(!beginMoving) return false;
obj.style.top = (event.clientY-obj.mouseDownY);
obj.style.left = (event.clientX-obj.mouseDownX);
}
function MUTM(obj){
if(!beginMoving) return false;
obj.releaseCapture();
obj.style.top=0;
obj.style.left=0;
obj.style.zIndex=0;
beginMoving=false;
var tempTop=event.clientY-obj.mouseDownY;
var tempRowIndex=(tempTop-tempTop%25)/25;
if(tempRowIndex+obj.rowIndex <0 )tempRowIndex=-1;
else tempRowIndex=tempRowIndex+obj.rowIndex;
if(tempRowIndex >= obj.parentElement.rows.length-1) tempRowIndex = obj.parentElement.rows.length-1;
obj.parentElement.moveRow(obj.rowIndex,tempRowIndex);
}</SCRIPT>
<TABLE width=300 border=1>
<TBODY>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD bgColor=blue>0</TD>
<TD>0</TD>
<TD>0</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD bgColor=black>1</TD>
<TD>1</TD>
<TD>1</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD bgColor=red>2</TD>
<TD>2</TD>
<TD>2</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD>3</TD>
<TD>3</TD>
<TD>3</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD>4</TD>
<TD>4</TD>
<TD>4</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD>5</TD>
<TD>5</TD>
<TD>5</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD>6</TD>
<TD>6</TD>
<TD>6</TD></TR>
<TR onmouseup=MUTM(this); onmousemove=MMTM(this)
onmousedown=MDTM(this) style="POSITION: relative; HEIGHT: 25px"
bgColor=#ffffff>
<TD>7</TD>
<TD>7</TD>
<TD>7</TD></TR></TBODY></TABLE>
</BODY></HTML>