获取被拖动的对象的ID
获取被拖动的对象的ID <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME='Generator' CONTENT='EditPlus'>
<META NAME='Author' CONTENT=''>
<META NAME='Keywords' CONTENT=''>
<META NAME='Description' CONTENT=''>
</HEAD>
<BODY>
<SCRIPT LANGUAGE='JavaScript'>
<!--
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var y;
var dobj;
function movemouse(e)
{
if (isdrag)
{
dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
return false;
}
}
function selectmouse(e)
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? 'HTML' : 'BODY';
while (fobj.tagName != topelement && fobj.className != 'dragme')
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}
if (fobj.className=='dragme')
{
isdrag = true;
dobj = fobj;
//alert(dobj.id);显示被拖动图片的ID
ty = parseInt(dobj.style.top+0);
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function('isdrag=false');
//-->
</SCRIPT>
<style>.dragme{position:relative;}</style>
<img src="http://doc.readmen.com/10/images/1.jpg" id='image1' /<img src="http://doc.readmen.com/10/images/2.jpg" id='image2' /<img src="http://doc.readmen.com/10/images/3.jpg" id='image3' /</HTML>