-
Notifications
You must be signed in to change notification settings - Fork 0
/
paste-test.html
34 lines (28 loc) · 1.07 KB
/
paste-test.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h2>Paste here to see contents of clipboard:</h2>
<div style="width: 200px; height: 200px; border: 1px solid black; overflow: auto;" contenteditable="true" id="test"></div>
<br>
<h2>Content Analysis:</h2>
<textarea id="content-report" cols="100" rows="20"></textarea>
<script>
document.getElementById('test').addEventListener('paste', function(e) {
var items = e.clipboardData.items;
var contents = '';
for (var i = 0; i < items.length; i++) {
console.log(items[i].type, e.clipboardData.getData(items[i].type));
contents += 'Type:\n' + items[i].type + '\n\n';
contents += 'Content:\n' + e.clipboardData.getData(items[i].type) + '\n---------------------------------\n\n';
document.getElementById('content-report').innerHTML = contents;
}
})
</script>
</body>
</html>