Daily Archives: July 2, 2007

Dragging an Image in IE

I had a requirement to drag an image. So, I implemented the onmousedown, onmouseup and onmousemove on the image and it worked fine in Firefox. One thing I had to do is to prevent the default browser behavior taking place. This can be done in Firefox using event.preventDefault(); Preventing an event in IE is done differently, using event.cancelBubble = false; and event.returnValue = false; So, I used these two statements for IE. But it didn’t work. IE was still ending up using the default image dragging behavior.

So, after a bit of research, I did the same preventing of default image for IE but on the ondragstart event of the image. Now I can drag the image in both IE and Firefox to achieve a custom drag behavior.

Leave a comment

Filed under IE, javascript