Hallo allerseits!
Ich hab ein kleines Problem mit einem mouseover-Effekt.
Die Lösung ist wahrscheinlich naheliegend, aber ich steh da irgendwie auf der Leitung...
Ich will, dass wenn man über ein bestimmtes Element fährt, ein div an der Stelle erscheint. Das passiert auch, nur immer und immer wieder ...
Wie kann man das ändern?
Mein Code ist der:
Code:
<html>
<head>
<title>Balloon</title>
<script type="text/javascript">
/* get top-position of element */
function abstop(i) { return (i.offsetParent) ? i.offsetTop+abstop(i.offsetParent) : i.offsetTop; }
function absleft(i){ return (i.offsetParent) ? i.offsetLeft+absleft(i.offsetParent) : i.offsetLeft; }
function showBalloon(mouse, id, img, text) {
oDiv = document.getElementById(id);
yPos = abstop(mouse)+5;
xPos = absleft(mouse)+5;
oDiv.style.left = xPos+'px';
oDiv.style.top = yPos+'px';
oDiv.style.display = 'block';
oDiv.innerHTML = '[img]'+img+'[/img]
'+text;
}
function hideBalloon(id) {
document.getElementById(id).style.display = 'none';
}
</script>
</head>
<body>
<div style="width:50px; height:50; background:blue;" onmouseover="javascript:showBalloon(this, 'id_1', '../img/labels/bg_library.gif', 'text text text')" onmouseout="javascript:hideBalloon('id_1')"></div>
xxx
<div style="width:50px; height:50; background:blue;" onmouseover="javascript:showBalloon(this, 'id_1', '../img/labels/bg_library.gif', 'text text text')" onmouseout="javascript:hideBalloon('id_1')"></div>
xxx
<div style="width:50px; height:50; background:blue;" onmouseover="javascript:showBalloon(this, 'id_1', '../img/labels/bg_library.gif', 'text text text')" onmouseout="javascript:hideBalloon('id_1')"></div>
xxx
<div style="width:50px; height:50; background:blue;" onmouseover="javascript:showBalloon(this, 'id_1', '../img/labels/bg_library.gif', 'text text text')" onmouseout="javascript:hideBalloon('id_1')"></div>
xxx
<div style="width:50px; height:50; background:blue;" onmouseover="javascript:showBalloon(this, 'id_1', '../img/labels/bg_library.gif', 'text text text')" onmouseout="javascript:hideBalloon('id_1')"></div>
xxx
<div id="id_1" style="position:absolute; width:118px; height:123; text-align:center; background:url(../img/balloon.gif); display:none;"></div>
</body>
</html>
Vielen Dank im Vorraus für jede Antwort!