Solved

Image following cursor

Posted on 2004-09-07
5
521 Views
Last Modified: 2008-02-01
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
Comment
Question by:PSERK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 11997879
0
 
LVL 8

Accepted Solution

by:
radnor earned 500 total points
ID: 11998166
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11998711
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11998717
Sorry, remove the window.status line. It was only for debugging.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question