onlydropzone.html (1978B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Modifier keys being used with a dropzone attribute</title> 5 <style type="text/css"> 6 div:first-child { 7 height: 100px; 8 width: 100px; 9 background: orange; 10 display: inline-block; 11 } 12 div:first-child + div { 13 height: 100px; 14 width: 100px; 15 background: blue; 16 display: inline-block; 17 } 18 div:first-child + div + div { 19 height: 100px; 20 width: 100px; 21 background: fuchsia; 22 display: inline-block; 23 } 24 table { 25 display: inline-table; 26 margin-right: 1em; 27 border-collapse: collapse; 28 } 29 table, th, td { 30 border: 1px solid black; 31 } 32 thead th { 33 background: silver; 34 color: black; 35 } 36 </style> 37 <script type="text/javascript"> 38 window.onload = function () { 39 var orange = document.getElementsByTagName('div')[0]; 40 orange.ondragstart = function (e) { 41 e.dataTransfer.setData('text/plain','http://example.com/'); 42 e.dataTransfer.effectAllowed = 'copy'; 43 }; 44 var fuchsia = document.getElementsByTagName('div')[2]; 45 fuchsia.ondrop = function (e) { 46 //dropzone overrides the modifier, always, and ignores effectAllowed 47 e.preventDefault(); 48 document.getElementsByTagName('div')[3].innerHTML = ( e.dataTransfer.dropEffect == 'link' ) ? 'PASS' : 'FAIL'; 49 }; 50 }; 51 </script> 52 </head> 53 <body> 54 55 <div draggable="true"></div> 56 <div></div> 57 <div dropzone="link string:text/plain"></div> 58 <div> </div> 59 <ol> 60 <li>Drag the orange square over the blue square</li> 61 <li>Press the relevant modifier keys for your platform to request a "move" drop effect (eg. Shift on Windows/Unix/Linux, Command on Mac)</li> 62 <li>Continue dragging over the pink square</li> 63 <li>If supported by the platform, the mouse cursor should show that a "link" drop effect will be used</li> 64 <li>Release the drag, then the keys</li> 65 <li>Fail if no new text appears above this list</li> 66 </ol> 67 <noscript><p>Enable JavaScript and reload</p></noscript> 68 69 </body> 70 </html>