•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,939 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,851 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 409 | Replies: 1
![]() |
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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:
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
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
•
•
Join Date: Aug 2008
Posts: 375
Reputation:
Rep Power: 1
Solved Threads: 34
I think I would have to see the context that this script is run in -- the html and if any more javascript. Maybe create a basic (as small as possible) example of the entire page and post it here.
I did find a couple errors in the above though.
...do something... as plain text, and the following break; both are trouble makers.
Looking forward to seeing the rest of this script-page.
I did find a couple errors in the above though.
...do something... as plain text, and the following break; both are trouble makers.
Looking forward to seeing the rest of this script-page.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: IE problem with CSS / Bible Forum
- Next Thread: how to generate rows in table dynamically


Linear Mode