Drag and Drop across Windows

Posted on 2013-02-01
Last Modified: 2013-02-01
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.
Question by:steva
LVL 11

Accepted Solution

mcnute earned 500 total points
ID: 38843309
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

Author Comment

ID: 38844768
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.


Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (, typical array handling might look like this: (CODE) B…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question