View Full Version : contentEditable - drag 'n drop images while following mouse trails

03-22-2005, 11:44 PM
okay. this is a question about contentEditable. As you know, you can drag an image, from around the object that is contentEditable=true and drag it into your editable object. You can drag 'n drop text, images, etc.. I'm trying to create a set of functions that will be triggered as soon as the user tries to drag an image, it will drag the image along side the mouse pointer, until the mouse button is released.

a) I've managed to create the set of functions to triggered the image
trailing after the mouse pointer.
b) My problem arises when the user tries to drag the image, when the mouse
button goes down, the "document.onmousemove = drag" does not function
like it is supposed to!

For example, this code will update the window status bar with the current mouse X axis ONLY WHEN the mouse button goes down, when it goes up, it will stop to update window.status. Now, try to put this code in a page with some text and images. Try to select text, first, and then try to drag it, OR try to drag images. Does the window.status get updated while dragging? NO!


function goDown(e) {
document.onmousemove = drag;

function drag(e) {
window.status = window.event.clientX;

function goUp(e) {
document.onmousemove = null;

03-24-2005, 03:30 PM
Try using appropriate events, such as ondragstart, etc.