L
Luke Skywalker
Hi guys,
I have to simulate the removing of a file in Windows with Javascript: in
other words I drag an image above a layer and the image disappears (like the
recycle bin).
I know (or better I thought to know) the way to write the script: in effect
I'm not able to indicate to browser that the image is above the layer.
This is the code (in short):
<img id="to_remove" title="File unnecessary" />
<div id="recycle_bin" onmouseover="verify('onmouseover');"
onmouseout="verify('onmouseout');">
The recycle bin. Drag an image here to remove it.
</div>
The function verify() is:
var recycle_bin=false;
function verify(_event) {
if (_event=="onmouseover") {
recycle_bin=true;
} else if (_event=="onmouseout") {
recycle_bin=false;
}
}
After, in the document.onmouseup event:
document.onmouseup=function() {
// ...here the code to stop drag'n'drop
if (recycle_bin) {
alert("Image removed");
}
}
The trouble is that when I drag the image above the layer, the onmouseover
event of the layer is not executed (in effect the cursor is onmouseover the
image I'm dragging). How can I do? Do you have alternative ideas or you know
how script.aculo.us do?
Thanks in advance.
I have to simulate the removing of a file in Windows with Javascript: in
other words I drag an image above a layer and the image disappears (like the
recycle bin).
I know (or better I thought to know) the way to write the script: in effect
I'm not able to indicate to browser that the image is above the layer.
This is the code (in short):
<img id="to_remove" title="File unnecessary" />
<div id="recycle_bin" onmouseover="verify('onmouseover');"
onmouseout="verify('onmouseout');">
The recycle bin. Drag an image here to remove it.
</div>
The function verify() is:
var recycle_bin=false;
function verify(_event) {
if (_event=="onmouseover") {
recycle_bin=true;
} else if (_event=="onmouseout") {
recycle_bin=false;
}
}
After, in the document.onmouseup event:
document.onmouseup=function() {
// ...here the code to stop drag'n'drop
if (recycle_bin) {
alert("Image removed");
}
}
The trouble is that when I drag the image above the layer, the onmouseover
event of the layer is not executed (in effect the cursor is onmouseover the
image I'm dragging). How can I do? Do you have alternative ideas or you know
how script.aculo.us do?
Thanks in advance.