javascript 是否可以使用 JQuery 或其他方法在两个浏览器窗口之间拖放某些内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10781194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to drag and drop some content between two browser windows using JQuery or another method?
提问by user1421214
Basically, I have a popup window and I want ability to drag and drop an html item back to parent opener window. For example, if there is an image on the popup window which is draggable (and basically a handler only), once I drop it in the drop-zone of the parent window I just need to copy a hidden ID and/or maybe name of the Image from the popup to the parent window.
基本上,我有一个弹出窗口,我希望能够将一个 html 项目拖放到父开启器窗口。例如,如果弹出窗口上有一个可拖动的图像(基本上只有处理程序),一旦我将它放在父窗口的放置区中,我只需要复制隐藏的 ID 和/或可能的名称从弹出窗口到父窗口的图像。
I can see plenty of examples on same page drag and drop but across windows? Is it possible? Both these windows have same website opened so I suppose there shouldn't be any cross-site issue thing?
我可以在同一页面拖放但跨窗口看到很多示例?是否可以?这两个窗口都打开了相同的网站,所以我想不应该有任何跨站点问题吗?
Could you point me to the right direction? Anything not clear please ask.
你能指出我正确的方向吗?有什么不清楚的请追问。
EDIT
编辑
Is HTML5 an option?
HTML5 是一种选择吗?
Another EDIT
另一个编辑
Is there another way to achieve above? i.e. different method than drag and drop - I am interested in transferring some data between one window to another here. Any ideas will be appreciated.
有没有另一种方法可以实现上述目标?即与拖放不同的方法 - 我有兴趣在一个窗口之间传输一些数据到另一个窗口。任何想法将不胜感激。
回答by zupa
You are after the HTML5 Drag and Drop API
您追求的是 HTML5 拖放 API
A pretty good description: DnD Basics
一个很好的描述:DnD Basics
You can even drag and drop stuff between Firefox and Chrome. Safari is missing the drop event, should be out in the next release (6 if I'm right). Opera & IE is not supporting it yet.
您甚至可以在 Firefox 和 Chrome 之间拖放内容。Safari 缺少 drop 事件,应该在下一个版本中发布(如果我是对的,则为 6)。Opera 和 IE 尚不支持它。