Mam taki skrypt i nie wiem dlaczego onmouseout jest ignorowane kiedy uruchomi się skrypt tworzenia diva (show()winksmiley.jpg.
A drugie to dlaczego onmousemove = move; w funkcji show(); działa a kiedy dodam przed document. już nie?
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var IE = document.all ? true : false;
  5. if (!IE) document.captureEvents(Event.MOUSEMOVE);
  6.  
  7. document.onmousemove = myMouseXY;
  8. var pX = 0;
  9. var pY = 0;
  10.  
  11. function myMouseXY(e) {
  12. if (IE) {
  13. pX = event.clientX + document.body.scrollLeft;
  14. pY = event.clientY + document.body.scrollTop;
  15. } else {
  16. pX = e.pageX;
  17. pY = e.pageY;
  18. }
  19. if (pX < 0) pX = 0;
  20. if (pY < 0) pY = 0;
  21. return true;
  22. }
  23.  
  24. function show()
  25. {
  26. onmousemove = move;
  27. function move()
  28. {
  29. var chmurka = document.getElementById("show");
  30. if (chmurka != null)
  31. {
  32. remove();
  33. }
  34. var div = document.getElementById("dymek");
  35. var add = document.createElement("div");
  36. add.setAttribute("style", "position: absolute; top: "+pY+"px; left: "+pX+"px; height: 131px; width: 179px; background-color: red;");
  37. add.setAttribute("id", "show");
  38. div.appendChild(add);
  39. }
  40. }
  41.  
  42. function remove()
  43. {
  44. var div = document.getElementById("dymek");
  45. div.removeChild(div.childNodes[0]);
  46. }
  47.  
  48. </script>
  49. </head>
  50. <body >
  51. <div id="dymek" style="position: absolute;"></div>
  52. <div id="test" onmouseover="show();" onmouseout="remove();" style="position: absolute; top: 20px; left: 11px; height: 131px; width: 179px; background-color: black;">test</div>
  53. </body>
  54. </html>
  55.