拖曳使用jQuery UI跨框架 [英] Drag & drop across frames with jQuery UI

查看:103
本文介绍了拖曳使用jQuery UI跨框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样做:


  • 从包含IFRAME的第一个文档拖动DIV元素

  • Drag a DIV element from a first document that contains an IFRAME

将此DIV元素放入IFRAME内的第二个文档。

Drop this DIV element into into a second document, inside the IFRAME.

有没有办法使用jQuery UI draggable&可以实现这一点吗?或者以跨浏览器方式执行此操作,可能还有另一个JS库?

Is there a way to use jQuery UI draggable & droppable to achieve this? or otherwise do this in a cross-browser way, possibly with another JS library?

推荐答案

您可以通过访问iframe中的内容与jQuery这样的方式:

You can easily do this by accessing the contents inside the iframe with jQuery this way:

$( 'your-iframe' ).contents().find( 'elements-to-find' ).droppable();

为了确保在运行脚本时加载iframe内容,您必须等待jQuery加载iframe的事件。

To make sure the iframe contents are loaded when you run the script, you must wait for the jQuery load event of the iframe.

$('your-iframe').load(function() {

    $( 'your-iframe' ).contents().find( 'elements-to-find' ).droppable();

});

我有同样的需要,并设法在iframe之间拖放,以及所有正常工作。

I had the same necessity of you and managed to do drag and drop between iframes this way, and everything worked correctly.

这篇关于拖曳使用jQuery UI跨框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆