-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDragAndDropExample03.htm
executable file
·30 lines (27 loc) · 1.06 KB
/
DragAndDropExample03.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html>
<head>
<title>Custom Drop Target Example</title>
<script src="EventUtil.js"></script>
</head>
<body>
<p>Try dragging the image over the square.</p>
<p>Firefox will navigate away, other browsers won't.</p>
<img id="smiley" src="smile.gif">
<div style="width: 100px; height: 100px; float: right; background: red" id="droptarget"></div>
<div id="output"></div>
<script>
var droptarget = document.getElementById("droptarget");
function handleEvent(event){
document.getElementById("output").innerHTML += event.type + "<br>";
if (event.type == "dropenter" || event.type == "dragover"){
EventUtil.preventDefault(event);
}
}
EventUtil.addHandler(droptarget, "dragenter", handleEvent);
EventUtil.addHandler(droptarget, "dragover", handleEvent);
EventUtil.addHandler(droptarget, "dragleave", handleEvent);
EventUtil.addHandler(droptarget, "drop", handleEvent);
</script>
</body>
</html>