Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 533
  • Last Modified:

Image following cursor

Hi Programmers!
I am not JavaScript programmer but I have to make a little script:
I need an small image that constantly follows a cursor.
Something like you move a cursor and with a small delay an image will follow it or something like that.

If possible then please help!!!

Okey, all the best!
0
PSERK
Asked:
PSERK
  • 2
1 Solution
 
radnorCommented:
http://javascript.internet.com/messages/mouse-trails.html

Change the image they provide (an arrow) to your image you should be good to go.
0
 
ZvonkoSystems architectCommented:
Here my version:


<html>
<head>
<script>
var imgCur = null;
function moveImg(e){
  if(!e){
    e=event;
  } else {
    e.x = e.pageX;
    e.y = e.pageY;
  }
  setTimeout("imgCur.style.left='"+e.x+"px';imgCur.style.top='"+e.y+"px'", 100);
  status="imgCur.style.left='"+e.x+"px';imgCur.style.top='"+e.y+"px'";
}
function intitCur(){
  imgCur=document.images.curImg;
  if(!document.all)
    document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=moveImg;
}
</script>
</head>
<body onLoad="intitCur()">
<img name="curImg" style="position:absolute;" src="http://experts-exchange.com/images/vipAccess.gif">
</body>
</html>


0
 
ZvonkoSystems architectCommented:
Sorry, remove the window.status line. It was only for debugging.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now