close-drag-004-manual.html (1006B)
1 <!doctype html> 2 <title>drag & drop - manually closing a tab while a drag is in operation</title> 3 <style type="text/css"> 4 p.gone, ul { display: none; } 5 p.gone + ul { display: block; } 6 </style> 7 <script type="text/javascript"> 8 window.onload = function() { 9 if( location.href.match(/#popup$/) ) { document.getElementsByTagName('p')[0].className = 'gone'; } 10 document.getElementsByTagName('ul')[0].ondragstart = function(e) { 11 e.dataTransfer.effectAllowed = 'copy'; 12 e.dataTransfer.setData('Text', 'dummy text'); 13 }; 14 }; 15 </script> 16 <p><a href="#popup" target="_blank">Open this page in a new tab</a>.</p> 17 <ul draggable='true'> 18 <li>Drag this text downwards, and do not release the drag.</li> 19 <li>Use a keyboard shortcut (eg. Ctrl+W on Windows) to close the tab.</li> 20 <li>The browser may optionally cancel the drag. The browser may optionally close the tab. Fail if the drag placeholder gets stuck. Fail if the browser crashes.</li> 21 </ul> 22 <noscript><p>Enable JavaScript and reload</p></noscript>