Drag and Drop across Windows

I have a page that loads and then that page's JavaScript opens a popup window that will become a gallery. The user will upload images, using JavaScript and PHP that is part of the popup gallery window, and these uploaded  images will be displayed in the gallery window that we popped up

Once several images have been uploaded and displayed in the gallery window I would like to drag and drop them into the primary window. Actually I'd like to leave the image in the gallery and just drag a ghost image across and drop it in the main window, so we end with the image in both windows.

This seems a bit tricky since the main widow and the popup gallery window are different JavaScript execution contexts.  How can I implement a jQuery (or YUI) Drag and Drop that works from the popup window to the main window?

Thanks for any ideas.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

mcnuteConnect With a Mentor Commented:
You cannot do this through windows, but you should consider modals which imitates the behavior of your popup but is in the same dom as your main window.

Consider a jquery dialogue
stevaAuthor Commented:
Hmmmm.  Ok.  I've used jQuery dialogs before.  Basically they're just a div that gets its display mode  set to none or to  block and they're certainly in the same DOM as everything else in the viewport so the Drag and Drop should work fine.  

The dialog would have to have a form with an input type:file to get the images to upload, but that shouldn't be a problem.

I was following the path TinyMCE took with their Rich-text editor.  When you click the button  in the TinyMCE toolbar to insert an image a new popup window is opened that has  a form to get the image. The image is then transferred into the RTE window by calling a function back in the RTE window's  javascript with something like

Open in new window

But this inserts the image wherever the cursor is in the RTE window and I want to be able to drop it anywhere, so I wanted to employ Drag and Drop.

I'm wondering now why TinyMCE went to all the trouble of opening a new window, instead of using a dialog.

I gave you the points for your suggestion.  If you happen to have any thoughts on the above I'd  be interested.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.