Buenas,
Tengo un div en el cual se puede arrastrar pero lo que me falta es que cuando ese div lo arrastre sobre un td me salte la informacion del div.
dejo mi codigo
Código HTML:
Ver original<html xmlns="http://www.w3.org/1999/xhtml"> .objMovible{
position:absolute;
cursor:pointer;
z-index:1;
left: 16px;
top: 17px;
}
<script type="text/javascript"> //Si el navegador del cliente es Mozilla la variable siguiente valdrá true
var moz = document.getElementById && !document.all;
//Flag que indica si estamos o no en proceso de arrastrar el ratón
var estoyArrastrando = false;
//Variable para almacenar un puntero al objeto que estamos moviendo
var dobj;
function arrastrarRaton(e){
if (estoyArrastrando) {
newLeft = moz ? e.clientX : event.clientX;
newTop = moz ? e.clientY : event.clientY;
//alert(newLeft - parseInt(dobj.style.width)/2);
dobj.style.left = newLeft - parseInt(dobj.style.width)/2;
dobj.style.top = newTop - parseInt(dobj.style.height)/2;
return false;
}
}
function soltarBoton(e) {
estoyArrastrando = false;
}
function presionarBoton(e) {
//Obtenemos el elemento sobre el que se ha presionado el botón del ratón
var fobj = moz ? e.target : event.srcElement;
//alert(fobj.parentNode);
// Buscamos el primer elemento en la que esté contenido aquel sobre el que se ha pulsado
// que pertenezca a la clase objMovible.
while (fobj.tagName.toLowerCase() != "html" && fobj.className != "objMovible") {
fobj = moz ? fobj.parentNode : fobj.parentElement;
}
// Si hemos obtenido un objeto movible...
if (fobj.className == "objMovible") {
// Activamos el flag para indicar que se empieza a arrastrar
estoyArrastrando = true;
// Guardamos un puntero al objeto que se está moviendo en la variable global
dobj = fobj;
// Devolvemos false para no realizar ninguna acción posterior
return false;
}
}
document.onmousedown = presionarBoton;
document.onmouseup = soltarBoton;
document.onmousemove = arrastrarRaton;
document.oncontextmenu=new Function("return false");
<div class="objMovible" style="width:80px;height:80px;background-color:#CC0000"></div><br> <table width="200" border="1">
Alguna idea???
Saludos