简体   繁体   English

一旦开始任何对象拖动,如何使 iframe 跟随鼠标光标?

[英]How to make the iframe follow the mouse cursor as soon as any object drag is started?

How to make the iframe follow the mouse cursor as soon as the drag (of any object eg. image, text, etc.) is started?一旦开始拖动(任何对象,例如图像、文本等),如何使 iframe 跟随鼠标光标?

Thanks in advance.提前致谢。

Usually mouse events from elements inside an iframe don't propagate to the frame itself.通常,来自 iframe 内元素的鼠标事件不会传播到框架本身。 You can add handlers to the elements inside the frame to do trigger the necessary events on the iframe.您可以向框架内的元素添加处理程序,以触发 iframe 上的必要事件。

A simple example using jQuery UI:一个使用 jQuery UI 的简单示例

var $els = $("*", frames['frame'].document );
$els.bind("mousedown mousemove mouseup",function(e) { $('#frame').trigger(e); })
$els.bind("drag",function(e) { $('#frame').trigger(e); return false; });

$('#frame').draggable();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM