<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> var IE = document.all?true:false var tempX = 0 var tempY = 0 var XX = 100 var YY = 100 function getMouseXY(e) { if (window.IE) { // grab the x-y pos.s if browser is IE tempX = event.clientX + document.body.scrollLeft tempY = event.clientY + document.body.scrollTop } else { // grab the x-y pos.s if browser is NS tempX = e.pageX tempY = e.pageY } // catch possible negative values in NS4 if (tempX < 0){tempX = 0} if (tempY < 0){tempY = 0} window.XX = 10; document.getElementById('xxx').value = "X:" + tempX; document.getElementById('yyy').value = "Y:" + tempY; document.getElementById('czas').style.width = tempX + "px"; document.getElementById('czas').style.height = tempY + "px"; document.getElementById('czas').style.left = tempX + "px"; document.getElementById('czas').style.top = tempY + "px"; return true } function count(){ if (!IE) document.captureEvents(Event.MOUSEMOVE) document.onmousemove = getMouseXY; window.YY = document.getElementById('xxx').value.toString(); document.getElementById('ggg').value = window.XX; document.getElementById('hhh').value = window.YY; } </script> </head> <body> <div id="czas" style="background-color: aqua; width: 500px; position: absolute; t"> <input id="xxx" name="strength" value="" /> <input id="yyy" name="strength" value="" /> </div> <input id="ggg" name="strength" value="" /> <input id="hhh" name="strength" value="" /> </body> </html>
I wewnątrz funkcji getMouseXY() nie mogę się dobrać do żadnej zmiennej globalnej XX ani YY. Próbowałem też normalnie, nie jako element klasy "window". Nie działa

Podobno
Jest przestarzałe dlatego należy używać addEventListener(), ale nigdzie nie mogę znaleźć o tym zrozumiałych informacji, a to co znalazłem na stronie mozilli jest kompletnie niejasne. http://developer.mozilla.org/pl/docs/DOM:e...ddEventListener
document.captureEvents(Event.MOUSEMOVE)