View Full Version : find target on onmouseup event in NS 7

06-04-2003, 10:55 PM
It's really URGENT ! Please help. I will give you 15 points.
This is a NS7 related question. I drag a div and drop it on a table row. When I drop the div on a table row I want to find out which row I drop that div on.

In my code I call 'dragEnd' function on 'onmouseup' event. In that function I do window.alert(e.target.id). This always returns the id of the div. But what I want is the id of the table row where I dropped the div on.

Please take a look at the simple html file. You can copy it and test it.
This problem seems like a very common problem, but I couldn't find a solution.
Or is coding for NS7 such a pain ?
Your help will be greatly appreciated.




var dragElement;

function getDraggableElement (target) {
if (target.className == 'dragDiv')
return target;
while ((target = target.parentNode));
return null;

function dragStart (e) {
dragElement = getDraggableElement (e.target);
if (dragElement) {
document.onmousemove = dragOn;

function dragOn (e) {
dragElement.style.left = e.clientX + 'px';
dragElement.style.top = (e.clientY+40) + 'px';

function dragEnd (e) {
document.onmousemove = null;
dragElement = null;

document.onmousedown = dragStart;
document.onmouseup = dragEnd;


.dragDiv {
border: 1px solid gray;
position: absolute;


<div id="dragOne" class="dragDiv">This is the dragable text</div>

<table id="tableOne" align="center" border="2">
<tr id="rowOne">
<td width="200" id="tdOne">Row One </td>

<tr id="rowTwo">
<td width="200" id="tdTwo">Row Two</td>