Add drag event listener to iframe

190 Views Asked by At

I create an iframe in JavaScript and add a drag enter event listener to it. I wrote a small sample here: Codepen

drag.addEventListener("dragenter", dragEnter, false)

It works well in codepen.

My real project is in a chrome extension. I write the same code but the dragenter event works only from left/top boundaries.

Thanks in advance!

1

There are 1 best solutions below

0
On BEST ANSWER

I found the problem is from

border: none;
outline: none;

Also I tested

frameBorder = 0
border = 0

They will affect the dragenter as well.

I don't know if it only happens in chrome extension, and here is my solution

As I need to remove the border, I used

border-color: transparent;

Done!