Marc: Mauskoordinaten die nte

Beitrag lesen

Guten Morgen,

hier mal mein Javascript-Code:

-----------------------------
var sn_subnoteID     = 'divSubnote';
var sn_bgColor    = '#FF0000';
var sn_posCursorTop  = 0;
var sn_posCursorLeft = 0;

function showSubnote()
{
 var divSubnote  = document.createElement('div');
 divSubnote.id   = sn_subnoteID;

var e   = window.event;
 var posX  = e.clientX;
 var posY  = e.clientY;

divSubnote.style.backgroundColor    = sn_bgColor;
 divSubnote.style.position           = 'absolute';
 divSubnote.style.left               = posX + sn_posCursorLeft;
 divSubnote.style.top                = posY + sn_posCursorTop;

document.body.appendChild(divSubnote);
 divSubnote      = document.getElementById(sn_subnoteID);
 divSubnote.innerHTML = 'sdsadsadsadsad';
}
-----------------------------

Hier der dazugehörige Funktionsaufruf in HTML (Nur zum Testen):
----------------------------
...
<div onMouseOver="showSubnote();" id="testDiv">
            Ich bin der Layer
        </div>
...
----------------------------