blob: ed05fcedea20c54d885432aa3d179dc344aec0fc (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
if (window.addEventListener) {
window.addEventListener('load', init, false); //W3C
} else {
window.attachEvent('onload', init); //IE
}
function init(event) {
var el = document.getElementById("drop");
if (el.addEventListener) {
el.addEventListener("dragover", dragover, false);
el.addEventListener("dragenter", dragenter, false);
el.addEventListener("drop", drop, false);
} else if (el.attachEvent) {
el.attachEvent('ondragover', dragover);
el.attachEvent('ondragenter', dragenter);
el.attachEvent('ondrop', drop);
}
}
function dragover(event) {
event.dataTransfer.dropEffect = 'copy';
return cancel(event);
}
function drop(event) {
document.getElementById("drop").innerHTML = event.dataTransfer.getData('Text');
return cancel(event);
}
function dragenter(event) {
return cancel(event);
}
function cancel(event) {
if (event.preventDefault) {
event.preventDefault();
}
return false;
}
</script>
</head>
<body>
<div id="drop">or over here</div>
</body>
</html>
|