Hi,
bin gerade dabei, das Problem ausfindig zu machen.
Also es ist so, dass bei der Seite der unten zu sehende JS Code dafür sorgt, dass die globalen Parameter mouseX (input Feld X) und mouseY (input Feld Y) immer die aktuellen Koordination des Cursors haben:
Das klappt auch sehr gut AUßER in dem problematischen Fall:
Wenn jemand (im Gecko Browser) auf ein image klickt und dabei die linke Maustaste gedrückt hält und den Cursor bewegt. Dann setzt das Script - warum auch immer - kurzzeitig aus, bis die Maustaste losgelassen wird.
Macht man das selbe beim DIV-Objekt ist es kein Problem. (Nachteil: die Drag&Drop Funktion fehlt, also dass das img bzw der div dem Cursor folgt, wenn man die Maus gedrückt hält und zieht...)
Konkretes Beispiel zum nachvollziehen:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Maus...</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
#imginnen { width:300px; height:100px; border:1px solid black;}
#divinnen { background:url(http://www.google.de/intl/de_de/images/logo.gif); width:300px; height:100px; border:1px solid black;}
</style>
<script type="text/javascript">
var mouseX=0;
var mouseY=0;
//4mouse actions:
init_mousemove();
//find out if ie runs in quirks mode
var docEl = (
typeof document.compatMode != "undefined" &&
document.compatMode != "BackCompat"
)? "documentElement" : "body";
// register event
// capture it for nc 4x
function init_mousemove() {
if(document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = dpl_mouse_pos;
document.onmouseup =function (){box2followthemouse='';};
}
// handle onmousemove event
function dpl_mouse_pos(e)
{
// position where mousemove fired
var xPos = e? e.pageX : window.event.x;
var yPos = e? e.pageY : window.event.y;
// for ie add scroll position
if (document.all && !document.captureEvents) {
xPos += document[docEl].scrollLeft;
yPos += document[docEl].scrollTop;
}
// display position
mouseX=xPos;
mouseY=yPos;
document.getElementById("x").value=mouseX;
document.getElementById("y").value=mouseY;
if(box2followthemouse!='')
attach2mouse(document.getElementById(box2followthemouse))
// for the dino pass event
if (document.layers) routeEvent(e);
}
</script>
</head>
<body>
<img id="imginnen" alt="IMAGE" src="http://www.google.de/intl/de_de/images/logo.gif"/>
<div id="divinnen">DIV</div>
<p>Mouse: <input id="x"><input id="y"></p>
</body>
</html>
Hoffe, ihr habt mir einen Tipp...