Follow mouse cursor with a layer - dHTML
Hi,
does anyone know of a tutorial or just some example code for a layer that follows the mouse cursor using the mousemove event?
Your help is appreciated,
Malte
----------
Malte Ubl - [red]Germany[/red] - http://goKewl.com/
[red]The beats of 1000 hearts inside...[/red] the merciless pulsation... [red]and all I know is I'll be back...[/red] back to trance nation!
JP Stones posted this at 03:03 — 19th October 1999.
They have: 2,390 posts
Joined: Nov 1998
I saw something like this at dynamicdrive.com a while back...
JP
----------
[red]The Next Step in Website Development [/red] - http://www.what-next.com
The Webmaster Promotion and Resource Center
Anonymous posted this at 18:48 — 19th October 1999.
They have: 5,633 posts
Joined: Jan 1970
I don't think this will work in Netscape - not much does!
<html><head><title></title>
<style>
BODY {
cursor: none;
}
#trackingImage {
position: absolute;
left: 0;
top: 0;
width: 1px;
weight: 1px;
background-color: #FF0000;
font-size: 1px;
}
</style>
</head>
<body
text="#000000"
bgcolor="#FFFFFF">
<div id="trackingImage"><img src="img.gif"></div>
<script language="JavaScript">
<!-- hide script from old browsers
var newYPos;
var newXPos;
function trackMouse() {
window.status = 'X' + event.clientX + ' Y' + event.clientY;
if (event.clientY < document.body.clientHeight) {
newYPos = document.body.scrollTop + event.clientY;
}
else {
newYPos = document.body.clientHeight - 1;
}
if (event.clientX < document.body.clientWidth) {
newXPos = document.body.scrollLeft + event.clientX;
}
else {
newXPos = document.body.clientWidth - 1;
}
trackingImage.style.pixelTop = newYPos -1;
trackingImage.style.pixelLeft = newXPos -1;
}
function reloadWindow() {
window.location.reload();
}
document.onmousemove = trackMouse;
window.onresize = reloadWindow;
// end hiding from old browsers -->
</script>
</body></html>
----------
[email protected]
http://go.to/hass
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.