I'm trying to retrieve a url of an image dropped into a div. This is the code I use:
$('#dropzone')
.bind('dragenter dragover', false)
.bind('drop', function(e) {
e.stopPropagation();
e.preventDefault();
alert(e.dataTransfer.getData('text'));
});
Thing is, while it works great when dragging and dropping unlinked images (I get the src
attribute of the img
element), when I try to do this with images that they are links( <a href="..."><img src="..."></a>
), I get the href
attribute of the a
element instead of the src
attribute of the img
element.
Any ideas?
I don't care about browser compatibility, I want to make it work in Firefox (or Chrome) only.
Edit: Here's how it looks like: http://jsfiddle.net/SPdHR/2/
(seems to be working only in Firefox by the way)