168.xhtml (1092B)
1 <?xml version="1.0" encoding="utf-8"?> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Moving text between contenteditable elements</title> 5 <style type="text/css"> 6 div + div[contenteditable] 7 {width:300px; 8 height:100px; 9 margin-top:20px; 10 padding:10px; 11 color:white; 12 background-color:navy;} 13 </style> 14 <script type="application/ecmascript"> 15 function check() 16 {var div = document.querySelectorAll('div'); 17 document.querySelector('p').firstChild.nodeValue = (!div[0].firstChild.nodeValue && div[1].firstChild.nodeValue == 'Drag me')?'PASS':('FAIL(' + div[0].firstChild.nodeValue + ')');} 18 </script> 19 </head> 20 <body onload="window.getSelection().selectAllChildren(document.querySelector('div'))"> 21 <p>Drag selected text to the blue box. Copy of selection should end up in the blue box once you drop it there.</p> 22 <div contenteditable="true" ondragstart="event.dataTransfer.effectAllowed = 'move'">Drag me</div> 23 <div ondragenter="event.preventDefault()" ondragover="event.preventDefault();" ondrop="window.setTimeout('check()',100)" contenteditable="true"/> 24 </body> 25 </html>