problem with javascript in Mozila Firefox??????urgent help required

Discussion in 'Programming' started by rechard, Dec 3, 2007.

  1. #1
    <SCRIPT LANGUAGE="JavaScript" type="text/javascript">

    currentX = currentY = 0; // initialize global position-tracking variables
    whichEl = null; // initialize global element-being-dragged variable

    function grabEl() // function for onmousedown
    {
    whichEl = event.srcElement;

    while (whichEl.id.indexOf("DRAG") == -1) {
    whichEl = whichEl.parentElement;
    if (whichEl == null) { return }
    }

    if (whichEl != activeEl) {
    whichEl.style.zIndex = activeEl.style.zIndex + 1;
    activeEl = whichEl;
    }

    whichEl.style.pixelLeft = whichEl.offsetLeft;
    whichEl.style.pixelTop = whichEl.offsetTop;

    currentX = (event.clientX + document.body.scrollLeft);
    currentY = (event.clientY + document.body.scrollTop);
    //document.write(currentX);

    }

    function moveEl() // function for onmousemove
    {
    if (whichEl == null) { return };

    newX = (event.clientX + document.body.scrollLeft);
    newY = (event.clientY + document.body.scrollTop);
    distanceX = (newX - currentX);
    distanceY = (newY - currentY);
    currentX = newX;
    currentY = newY;

    whichEl.style.pixelLeft += distanceX;
    whichEl.style.pixelTop += distanceY;
    event.returnValue = false;
    document.form1.hidden1.value=currentX;
    document.form1.hidden2.value=currentY;
    }

    function dropEl() // function for onmouseup
    {
    whichEl = null;

    }

    document.onmousedown = grabEl;
    document.onmousemove = moveEl;
    document.onmouseup = dropEl;

    I have used above code to drag and drop image in my application.
    it is working properly in IE.But i m not getting this functionality in Mozila .
    i am not getting the problem ,can anyone one help me to solve this problem?
    please help me as soon as possible.
    thank you in advance.
     
    rechard, Dec 3, 2007 IP