简体   繁体   中英

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?

Thanks in advance.

Usually mouse events from elements inside an iframe don't propagate to the frame itself. You can add handlers to the elements inside the frame to do trigger the necessary events on the iframe.

A simple example using 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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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