Note that there are some explanatory texts on larger screens.

plurals
  1. POCrossbrowser method to cancel a drop event in a content edittable div
    primarykey
    data
    text
    <p>I want to be able to dissalow images (and other stuff) from being dropped into a content editable div across browsers. I see how to do it for Chrome and IE. Firefox stubbornly refuses. The code snippet at <a href="http://jsbin.com/oqozo3" rel="nofollow noreferrer">http://jsbin.com/oqozo3</a> has an example which shows that the event is firing, I am canceling it, and in FF the image still appears. </p> <p>Basically, The following fails to work in FF</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;ContentEditable fails in FF&lt;/title&gt; &lt;script type="text/javascript"&gt; function init() { var target = document.getElementById("target"); if (target.addEventListener) { target.addEventListener ("dragenter", all, false); target.addEventListener ("dragover", all, false); target.addEventListener ("drop", all, false); target.addEventListener ("dragdrop", all, false); } else { target.attachEvent ("ondragenter", all, false); target.attachEvent ("ondragover", all, false); target.attachEvent ("ondrop", all, false); } } function all(event) { if (event.preventDefault) { event.preventDefault();} return false; } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="init();"&gt; &lt;div id="target" style="border: 1px solid black; height: 100px;" contenteditable="true"&gt;This is editable content&lt;/div&gt; &lt;div&gt; &lt;p&gt;I don't want the image to be draggable to the above div. Works in IE, Chrome, not firefox.&lt;/p&gt; &lt;img src="http://mozcom-cdn.mozilla.net/img/firefox-100.jpg"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I have already looked at: <a href="https://stackoverflow.com/questions/3033130/contenteditable-div-disabling-drag-and-drop">ContentEditable DIV - disabling drag and drop</a>, but the suggestions there also don't work in firefox.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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