user2546340
user2546340

Reputation: 78

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.

Upvotes: 0

Views: 636

Answers (1)

Joe
Joe

Reputation: 28366

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();

Upvotes: 1

Related Questions