knowram Posted January 21, 2007 Share Posted January 21, 2007 I have seen adds on different pages where there is a cat on the bottom of the image and when you move your mouse over the image a ball moves with it and the cat moves his head back and forth following the ball. Or ones where a target follows the mouse and you have to shout something. My question is what language provides this real time mouse tracking, and what is it called?I am trying to build this into a site. Thanks for any info Quote Link to comment https://forums.phpfreaks.com/topic/35128-mouse-tracking/ Share on other sites More sharing options...
mainewoods Posted January 21, 2007 Share Posted January 21, 2007 that language is javascript. I you do a search on google you will be able to find many free javascript 'mouse tracking' scripts that have visual effects that follow the mouse around. Quote Link to comment https://forums.phpfreaks.com/topic/35128-mouse-tracking/#findComment-165912 Share on other sites More sharing options...
bibby Posted January 21, 2007 Share Posted January 21, 2007 Here's a little something I've been playing with.[code]<html><script>document.onmousemove= function (e){followMouse(e); }function followMouse(e) { var posx = 0; var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } mark(posx,posy)}function mark(x,y){ var d = document.getElementById('coords') d.value=x+' x '+y; d.style.left=parseInt(x+20)+'px'; d.style.top =parseInt(y+20)+'px';}</script><input type="text" id="coords" style="position:absolute;top:0px;left:0px;"></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35128-mouse-tracking/#findComment-165930 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.