[Javascript] Image follows mouse

Troy III Ajnej trojani2000 at hotmail.com
Sat Sep 3 06:34:07 CDT 2005


Not sure if I got you right but try:
  1. position your mouse follower image absolutely
  2.give it exact height and width.
  3. give it some ID (mouseImage)

Than do the script
It's being written just now...

getting center height and width of the image
but if you don't like the image to show in center but in right and lower 
corner of the mouse
you might wanna remove the vars and the maths so the script can get even 
shorter
and simplier than this:
...
var cH=mouseImage.style.height/2, cW=mouseImage.style.width/2

function mousefollower(){
                      x = event.screenX
                      y = event.screenY
            myImage.style.posTop = y + cH
            myImage.style.posLeft = x + cW }

   document.onmousemove=mousefollower

I'm being this nice because you're from Ireland and I'm waiting for some 
important download to finish 2.

P.S. (Use it at your own risk. I never tested it!)

Regards
           Troy III
progressive art enterprise


>From: "SkyScanner" <skyscanner at eircom.net>
>Reply-To: "\[JavaScript List\]" <javascript at LaTech.edu>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Subject: [Javascript] Image follows mouse
>Date: Sat, 3 Sep 2005 10:49:18 +0100
>
>Hi there - in your goody-bag of scripts, has anyone got a script that moves
>an image around next to the current cursor ? I need one that works in
>Internet Explorer *AND* Mozilla.
>
>Tim in Ireland.
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




More information about the Javascript mailing list