Hello, I'm frustated because I can't solve a problem I've got.
I explain the develop envionment
i've got 3 frames in a page. In the left frame, i've got a tree which elements can be dragged to the main frame.
this is the code to simulate drag and drop action:
function handleMouseDown() {
//if (!document.all) return;
switch (event.button) {
case 1:
if (event.srcElement.className == "drag") {
swDrag = true;
document.onmousemove = handleMouseMove;
break;
}
break;
case 2:
break;
}
return (false);
}
function handleMouseMove() {
if (!swDrag) return;
oTemp = event.srcElement;
if (isOverDropTarget(event.clientX, event.clientY)){
oTemp.style.cursor = "pointer";
}
else{
oTemp.style.cursor = "no-drop";
}
window.event.returnValue = false;
}
function handleMouseUp() {
if (swDrag){
if (isOverDropTarget(event.clientX, event.clientY)){
...do something...
}
else{
alert("item can't be dropped in this area");
}
swDrag = false;
}
break;
}
function isOverDropTarget(iX, iY) {
var oTarget = parent.frames("mainFrame").document.getElementById("foo");
var iX1 = findPosX(oTarget)+350;
var iX2 = iX1 + oTarget.offsetWidth;
var iY1 = findPosY(oTarget);
var iY2 = iY1 + oTarget.offsetHeight ;
return (iX >= iX1 && iX <= iX2 && iY >= iY1 && iY <= iY2);
}
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
}
while (obj = obj.offsetParent);
}
return curleft;
}
function findPosY(obj) {
var curtop = 0;
if (obj.offsetParent) {
do {
curtop += obj.offsetTop;
}
while (obj = obj.offsetParent);
}
return curtop;
}
i don't know why but when i click in one item (text) and move it to other frame, the text of the left frame is selected.
could anyone help me??? thanks in advance