[Javascript] Image follows mouse
SkyScanner
skyscanner at eircom.net
Tue Sep 6 02:30:15 CDT 2005
Thanks for your function, Laurent - that works fine on Internet Explorer and
Firefox. Just for the record, here is the complete page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta content="text/html; charset=windows-1252" http-equiv=Content-Type>
</head>
<body>
<img src='cat1.gif' ID="myImage"
style="position:absolute;top:0px;left:-500px">
</img>
</body>
<script>
function mousefollower(e){
x = (!document.all)? e.pageX : event.x+document.body.scrollLeft;
y = (!document.all)? e.pageY : event.y+document.body.scrollTop;
document.getElementById('myImage').style.left = x;
document.getElementById('myImage').style.top = y;
}
document.onmousemove=mousefollower
</script>
</html>
Thanks to Troy for the inital help, too.
Laurent - I am so surprised that you are from London. With a name like
yours, I had always assumed you were from Mexico, or southern Europe, and
imagined you sitting on some sun-baked veranda to do your coding!
Tim in Ireland.
More information about the Javascript
mailing list