[Javascript] Image follows mouse

Laurent Muchacho elmuchacho at gmail.com
Mon Sep 5 05:37:10 CDT 2005


Hi Tim,

Just read you email found below the function sent by troy but working crowse browser 

function mousefollower(e){
x = (!document.all)? e.pageX : event.x+document.body.scrollLeft;

y = (!document.all)? e.pageY : event.y+document.body.scrollTop;

document.getElementById('myImage').style.left = x + 'px';

document.getElementById('myImage').style.top = y + 'px';

}

Hope that help 

Laurent from London UK



  ----- Original Message ----- 
  From: SkyScanner 
  To: [JavaScript List] 
  Sent: Sunday, September 04, 2005 9:42 AM
  Subject: Re: [Javascript] Image follows mouse


  Thanks for the ideas, Troy, but I couldn't get that to work in Mozilla/Firefox. In Internet Explorer it works fine, though.

  No, I didn't make the pointer invisible - I just needed it to follow nearby.

  Greetings to Pristina - its nice to meet you!

  Tim in Co.Sligo, in the North West of Ireland.

    ----- Original Message ----- 
    From: Troy III Ajnej 
    To: javascript at LaTech.edu 
    Sent: Sunday, September 04, 2005 3:49 AM
    Subject: Re: [Javascript] Image follows mouse


    Reposting: (Correcting yet another mistake of mine)

    Thanks anyway, I believe that the script will surely work now,
    but you have to tell me,
    how did you manage to make the mouse pointer get invisible,
    because I'm almost sure that this is why you need this kind of 
    script in the first place?!

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <HTML>
    <BODY>
    <img src='mypointer.gif' ID="myImage" 
    style="position:absolute;top:0px;left:-500px">
    </img>
    </BODY>
    <SCRIPT>
    //version 1.0 -Troy III- progresive art enterprise
    h = myImage.height/2, w = myImage.width/2;
    function mousefollower(){
               x=event.x
               y=event.y
        myImage.style.posLeft= x-h
        myImage.style.posTop = y-w }
    document.onmousemove=mousefollower
    </SCRIPT>
    </HTML>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    (the corrected [!and tested!] version)

    [It can't get shorter than this!]

    >Thanks very much for that, Troy - I'll work through it.

    No need for it now.

    >Where are you from ? I often wonder where everyone on the list is 
    >from.

    I don't that much, but I like the fact that you do.
    I'm from Pristina, Ancient Dardania, today a small piece of it: 
    Kosova.

    My best regards to you
    >Tim in Ireland.




----------------------------------------------------------------------------
    Find e-mail and documents on your PC instantly with the new MSN Search Toolbar-FREE! 


----------------------------------------------------------------------------


    _______________________________________________
    Javascript mailing list
    Javascript at LaTech.edu
    https://lists.LaTech.edu/mailman/listinfo/javascript



------------------------------------------------------------------------------


  _______________________________________________
  Javascript mailing list
  Javascript at LaTech.edu
  https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050905/82cf67c9/attachment.htm>


More information about the Javascript mailing list