blob: 90dd440f6c93c230f86b22fa42a6a60bb9d2f71c (
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
|
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Selection drag and drop from text input and text/plain aliases</title>
<style type="text/css">
div
{min-height:40px;
width:40px;
padding:40px;
text-align:center;
color:white;
background-color:navy;}
</style>
<script type="application/ecmascript">
function start(event)
{event.dataTransfer.effectAllowed = 'copy';
event.dataTransfer.setData('text/plain','PASS');}
function checkText(event)
{var a = event.dataTransfer.getData('text/plain'),
b = event.dataTransfer.getData('text'),
c = event.dataTransfer.getData('TEXT'),
d = event.dataTransfer.getData('TexT');
document.querySelector('div').appendChild(document.createTextNode((a == b && b == c && c == d && d == 'PASS')?' PASS ':' FAIL '))}
</script>
</head>
<body onload="document.querySelector('input').select()">
<p><input value="Drag me" ondragstart="start(event)"/></p>
<p>Drag selection above to the navy box below and drop it. You should see word PASS once you drop it.</p>
<div ondragenter="event.preventDefault()" ondragover="return false" ondrop="checkText(event)"/>
</body>
</html>
|