Mouse Position in FF

Discussion in 'JavaScript' started by AndyFarrell, Feb 21, 2008.

  1. #1
    Hey Everyone.
    can someone help me get this to work in FF and other mozilla-based browsers

    Code:
    var mosX = 0 ;
    var mosY = 0 ;
    function StetDiVPosition(obj)
    {
    document.getElementById('sShot').style.visibility="visible";
    mosX = event.clientX + document.body.scrollLeft ;
    mosY = event.clientY + document.body.scrollTop;

    document.getElementById('sShot').style.top=mosY-200;
    document.getElementById('sShot').style.left=mosX;
    document.getElementById('sShot').innerHTML='<img src='+obj+'>' ;
    }thanks in advance.
     
    AndyFarrell, Feb 21, 2008 IP
  2. greboguru

    greboguru Member

    Messages:
    78
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Hi,

    Where are you getting the event instance from? If your code works on IE but not the other browsers then check out the following reference on DOM event

    http://www.javascriptkit.com/domref/domevent.shtml

    Hope this helps
     
    greboguru, Feb 21, 2008 IP