| <?xml version="1.0" encoding="utf-8"?> |
| <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="500px" height="500px" viewBox="0 0 500 500"> |
| <title>SVG link drag and drop: helper file</title> |
| <textArea x="10" y="10" width="480" height="200" font-size="30">Drop circle onto gray box below. Box should turn green once circle is dropped.</textArea> |
| <rect x="10" y="220" width="480" height="270" fill="gray"/> |
| <script type="application/ecmascript"> |
| var rect = document.querySelector('rect'); |
| rect.addEventListener('dragenter', |
| function (event) |
| {event.preventDefault();} |
| ,false); |
| rect.addEventListener('dragover', |
| function (event) |
| {event.preventDefault();} |
| ,false); |
| rect.addEventListener('drop', |
| function (event) |
| {rect.setAttribute('fill',(event.dataTransfer.getData('text/uri-list').replace(/\r\n$/,'') == 'data:text/plain,1')?'green':'red');} |
| ,false); |
| </script> |
| </svg> |