Note that there are some explanatory texts on larger screens.

plurals
  1. PODom update issue
    text
    copied!<p>I'm trying to drag images from div to div making sure that only one is in a div at a time. It works great on Opera but fails in Chrome (and others). It appears to work until I update elements from javascript and then the updates don't appear to be refreshed internally in Chrome.</p> <p>I can drag either of the images to the third square but then everything is frozen. I'd love ideas to work around this.</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; .outer { width: 150px; height: 40px; } .square { float: left; width: 32px; height: 32px; margin: 1px; padding: 0px; border: 1px solid #aaaaaa; } &lt;/style&gt; &lt;script type="text/javascript"&gt; function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); ev.target.appendChild(document.getElementById(data)); lock(); } function lock() { var squares = document.getElementsByClassName("square"); for (var i = 0; i &lt; squares.length; i++) { if (squares[i].children.length == 0) { squares[i].ondragover = 'allowDrop(event)'; } else { squares[i].ondragover = ''; } } } function init() { document.write("&lt;div class='outer square' ondrop='drop(event)' ondragover='allowDrop(event)'&gt;&lt;img src='bb.png' alt='bb' id=1 class='movable' draggable=true ondragstart='drag(event)'&gt;&lt;/div&gt;"); lock(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; init(); &lt;/script&gt; &lt;div class='outer square' ondrop='drop(event)' ondragover='allowDrop(event)'&gt; &lt;img src="aa.png" alt='aa' id=2 class='movable' draggable=true ondragstart="drag(event)"&gt; &lt;/div&gt; &lt;div class='outer square' ondrop='drop(event)' ondragover='allowDrop(event)'&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload