views:

126

answers:

1

Cryptic title, but it's hard to explain. With Firefox, head over to http://images.google.com do a random search, and then drag the first search result to the URL bar. You'll see it it goes to the page that had the image anchor. Then click the "see full size image" link, and then drag the image to the address bar.

In the first example, it copied the anchor, not the image, to the address bar. And in the second example, it took the URL of the image itself.

Is there a way to get to the image inside the anchor? I'm using a drop target that's in an iframe on another domain, so targetting the img's directly and adding JS events is out.

I don't expect to be able to do this with straight JS (though I hope). In fact I'm not even sure if flash/actionscript can do this!

My thought is I need to set up a drop target and get details about the element that was dropped... if it's an anchor, I can dive into the DOM and get the img inside it. This, of course, assumes that the DOM element itself is what's being dragged and that the browser isn't just copying the link.

Any help would be much appreciated.

Cheers! -eli

A: 

If I understood correctly, you don't control the "origin" page at all and what gets to the destination (on an cross-domain iframe, no less!) is the URL of the A, not of the IMG inside the A.

It does not bode well...i don't think it can be done, neither with Flash (actually, I HOPE it cannot be done neither with flash, it would be a security hole)

I don't know if it will be of use to your particular problem, but: - If the outer domain is 'yours' and the only problem is that you can't change that page, but can add other pages to that same domain, then maybe there is hope.

  • You can add a second iFrame in your iFrame, that points to the first, outer, domain. In that iframe you can use "window.parent.parent" to access the outer frame and manipulate it to your heart's content.

  • Of course you won't be able to pass it back to the first iframe, but if you just want to display the image...

I found this technique in an MSDN article, but I cannot find it now to link to it...

Was it any help? It is a bit convoluted, I know.

Victor
The only reason I mentioned that the iframe is in a different domain is to prevent the replies of "just use jquery, onload, find all imgs, add the drag/drop script, and call it a day." In this case, i have no control over what's being dragged, but I DO know it's an img wrapped in an anchor. And on drop, the default action is to take the anchor itself. If I can access the drag object, hit its DOM, and get the img, I'd be set!Thanks for replying