PSERK
asked on
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!
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!
http://www.javascriptkit.com/script/cutindex18.shtml
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.l eft='"+e.x +"px';imgC ur.style.t op='"+e.y+ "px'", 100);
status="imgCur.style.left= '"+e.x+"px ';imgCur.s tyle.top=' "+e.y+"px' ";
}
function intitCur(){
imgCur=document.images.cur Img;
if(!document.all)
document.captureEvents(Eve nt.MOUSEMO VE);
document.onmousemove=moveI mg;
}
</script>
</head>
<body onLoad="intitCur()">
<img name="curImg" style="position:absolute;" src="https://www.experts-exchange.com/images/vipAccess.gif">
</body>
</html>
<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.l
status="imgCur.style.left=
}
function intitCur(){
imgCur=document.images.cur
if(!document.all)
document.captureEvents(Eve
document.onmousemove=moveI
}
</script>
</head>
<body onLoad="intitCur()">
<img name="curImg" style="position:absolute;"
</body>
</html>
Sorry, remove the window.status line. It was only for debugging.