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="ve rify('onmouseov er');"
onmouseout="ver ify('onmouseout ');">
The recycle bin. Drag an image here to remove it.
</div>
The function verify() is:
var recycle_bin=fal se;
function verify(_event) {
if (_event=="onmou seover") {
recycle_bin=tru e;
} else if (_event=="onmou seout") {
recycle_bin=fal se;
}
}
After, in the document.onmous eup event:
document.onmous eup=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.
--
Luke S.
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="ve rify('onmouseov er');"
onmouseout="ver ify('onmouseout ');">
The recycle bin. Drag an image here to remove it.
</div>
The function verify() is:
var recycle_bin=fal se;
function verify(_event) {
if (_event=="onmou seover") {
recycle_bin=tru e;
} else if (_event=="onmou seout") {
recycle_bin=fal se;
}
}
After, in the document.onmous eup event:
document.onmous eup=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.
--
Luke S.
Comment