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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s