146.xhtml (1037B)
1 <?xml version="1.0" encoding="utf-8"?> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Selection drag and drop and text/plain aliases</title> 5 <style type="text/css"> 6 div 7 {min-height:40px; 8 width:40px; 9 padding:40px; 10 text-align:center; 11 color:white; 12 background-color:navy;} 13 </style> 14 <script type="application/ecmascript"> 15 function checkText(event) 16 {var a = event.dataTransfer.getData('text/plain'), 17 b = event.dataTransfer.getData('text'), 18 c = event.dataTransfer.getData('TEXT'), 19 d = event.dataTransfer.getData('TexT'); 20 document.querySelector('div').appendChild(document.createTextNode((a == b && b == c && c == d && d == 'Drag me')?'PASS':'FAIL'))} 21 </script> 22 </head> 23 <body onload="window.getSelection().selectAllChildren(document.querySelector('p'))"> 24 <p>Drag me</p> 25 <p>Drag selection above to the navy box below and drop it. You should see word PASS once you drop it.</p> 26 <div ondragenter="event.preventDefault()" ondragover="return false" ondrop="checkText(event)"/> 27 </body> 28 </html>