Caros, tenho as seguintes funções em java script: var idDestino = "";
function move(o) {
o.style.left = window.event.x;
o.style.top = window.event.y;
}
function fnOnDrag() {
idDestino = "";
}
function fnHandleDragStart () {
var oData = window.event.dataTransfer;
// Set the effectAllowed on the source object.
oData.effectAllowed = "move";
}
function fnHandleDrop () {
// This function is called by the target object in the ondrop event.
var oTarg = window.event.srcElement;
// var oData = window.event.dataTransfer;
// Cancel default action.
fnCancelDefault();
// Set the content of the oTarget to the information stored
// in the data transfer object in the desired format.
// oTarg.innerText += oData.getData("text");
// alert(oTarg.id);
idDestino=oTarg.id;
}
function fnHandleDragEnter () {
// This function sets the dropEffect when the user moves the mouse over the target object.
var oData = window.event.dataTransfer;
// Cancel default action.
fnCancelDefault();
// Set the dropEffect for the target object.
oData.dropEffect = "move";
}
function fnCancelDefault () {
// Cancel default action.
var oEvent = window.event;
oEvent.returnValue = false;
}
function fnDragEnd() {
msg = 'Evento = ' + event.type + ' usado pelo id: ' + '"' + event.srcElement.id + '"';
alert("teste");
if (idDestino != ""){
alert(msg+"\nPress Enter twice to close this window\n\nO idDestino é: " + idDestino);
}
else
event.srcElement.returnValue = false;
}
Estas funções são chamadas por elementos HTML, por exemplo:
<body>
Imagem 1
<img id="image" src="../ponto/fotos/4.jpg" alt="img1" ondrag="fnOnDrag()" ondragend="fnDragEnd()" ondrop="fnHandleDrop()" ondragover="fnCancelDefault()" ondragenter="fnHandleDragEnter()" onmousedown="fnDragEnd()"/>
Imagem 2
<img id="target" src="../ponto/fotos/1.jpg" alt="img2" ondrag="fnOnDrag()" ondragend="fnDragEnd()" ondrop="fnHandleDrop()" ondragover="fnCancelDefault()" ondragenter="fnHandleDragEnter()" onmousedown="fnDragEnd()"/>
</body>
</html> Por enquanto, o código funciona apenas para lançar um "alert" com os ids de origem e destino do objeto. O problema é que esse código funciona no IE, mas não no Mozilla. Vocês têm alguma idéia de como eu poderia resolver isso? Os eventos colocados acima (ondrag, ondragend, ondrop, etc.) não funcionam no mozilla? Caso não seja possível, alguém conhece uma biblioteca que possa ser utilizada para isso no mozilla? Abraços...