User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2008
Posts: 1
Reputation: hombredelcubo is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
hombredelcubo hombredelcubo is offline Offline
Newbie Poster

Selected text when drag across frames...

  #1  
Aug 7th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2008
Posts: 375
Reputation: langsor is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 34
langsor langsor is offline Offline
Posting Whiz

Re: Selected text when drag across frames...

  #2  
Aug 12th, 2008
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC