My solution stands out as the most effective. Many answers do not work well on outdated browsers such as IE8, as they do not support e.preventDefault() and the ondragstart event. To make it compatible across all browsers, you need to block the mousemove event for this image. See the example below:
Using jQuery
$("#my_image").mousemove( function(e) { return false } ); // workaround for IE
$("#my_image").attr("draggable", false); // disable dragging via attribute
Without using jQuery
var my_image = document.getElementById("my_image");
my_image.setAttribute("draggable", false);
if (my_image.addEventListener) {
my_image.addEventListener("mousemove", function(e) { return false });
} else if (my_image.attachEvent) {
my_image.attachEvent("onmousemove", function(e) { return false });
}
This solution has been tested and proven effective even on IE8.