OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Get reference to dragged element when dropped on iframe

  • Thread starter Thread starter Andrew Foulds
  • Start date Start date
A

Andrew Foulds

Guest
I'm dragging and dropping a DIV from a parent window onto a nested iframe but I can't get any info on the dragged DIV. In the source of the iframe I have this

Code:
window.addEventListener('load', e => {
  let frm = document.body;
  frm.addEventListener("drop", droppedOn);
});

function droppedOn(ev) {
  ev.preventDefault();
  console.log(ev)
  ...

If I drag and drop a file from my desktop onto the iframe then there is data in dataTransfer which identifies the dropped file.

When I drag a DIV from the parent onto the iframe, dataTransfer is empty (which I guess is expected) but ev's srcElement, target, and toElement all reference a DIV that is used as a background in the iframe source, frmElement is null, and relatedTarget is null.

How can I get a reference to the DIV that was dragged from the parent window?

<p>I'm dragging and dropping a DIV from a parent window onto a nested iframe but I can't get any info on the dragged DIV. In the source of the iframe I have this</p>
<pre><code>window.addEventListener('load', e => {
let frm = document.body;
frm.addEventListener("drop", droppedOn);
});

function droppedOn(ev) {
ev.preventDefault();
console.log(ev)
...
</code></pre>
<p>If I drag and drop a file from my desktop onto the iframe then there is data in dataTransfer which identifies the dropped file.</p>
<p>When I drag a DIV from the parent onto the iframe, dataTransfer is empty (which I guess is expected) but ev's srcElement, target, and toElement all reference a DIV that is used as a background in the iframe source, frmElement is null, and relatedTarget is null.</p>
<p>How can I get a reference to the DIV that was dragged from the parent window?</p>
 
Top