Possible Duplicate:
How do we prevent default actions in JavaScript?
In the code below I try to create a zoom feature for Charts. I tested it on IE and it worked but when I try it on Firefox, it seems that the browser doesn't cancel the default action and tries to drag the whole image. I cannot figure out why it does not work!
<img onmousedown="startDrag" onmousemove="drag" onmouseup="stopDrag" src="ChartImageSource">
MouseDownPosition = null;
startDrag = function (s, e) {
    if (!this.MouseDownPosition && e.which == 1) {
        this.MouseDownPosition = {
            x: e.clientX,
            y: e.clientY
        };
        this.Box = document.createElement("div");
        $(this.Box).attr('id', 'zoomBox').css({ 'border-style': 'solid', 'border-color': 'black', 'border-width': '1px', 'position': 'absolute', 'z-index': '1000', 'left': e.clientX + 'px', 'top': e.clientY + 'px', 'width': '0px', 'height': '0px' });
        $(s).parent().append(this.Box);
    }
};
drag = function (s, e) {
    if (this.MouseDownPosition) {
        e.preventDefault();
        var initX = this.MouseDownPosition.x;
        var initY = this.MouseDownPosition.y;
        var curX = e.clientX;
        var curY = e.clientY;
        var left;
        var top;
        var width;
        var height;
        if (curX - initX >= 0) {
            width = curX - initX + 'px';
            left = initX + 'px';
        } else {
            width = -curX + initX + 'px';
            left = curX + 'px';
        }
        if (curY - initY >= 0) {
            height = curY - initY + 'px';
            top = initY + 'px';
        } else {
            height = -curY + initY + 'px';
            top = curY + 'px';
        }
        $(this.Box).css({ 'width': width, 'height': height, 'left': left, 'top': top });
    }
};
stopDrag = function (s, e) {
    if (this.MouseDownPosition) {
        var initX = this.MouseDownPosition.x;
        var initY = this.MouseDownPosition.y;
        var curX = e.clientX;
        var curY = e.clientY;
        var curOffX = e.offsetX;
        var curOffY = e.offsetY;
        var initOffX = ((curX - initX) ? initX - curX : -(initX - curX)) + curOffX;
        var initOffY = ((curY - initY) ? initY - curY : -(initY - curY)) + curOffY;
        var MinPixX = initOffX <= curOffX ? initOffX : curOffX;
        var MaxPixX = initOffX >= curOffX ? initOffX : curOffX;
        var MinPixY = initOffY <= curOffY ? initOffY : curOffY;
        var MaxPixY = initOffY >= curOffY ? initOffY : curOffY;
        s.parentNode.removeChild(this.Box);
        this.MouseDownPosition = null;
    }
};
 
     
     
     
    