(046)javascript_event_mouseevent
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>EVENT</title> 6 <style type="text/css"> 7 #myDiv { 8 width: 100px; 9 height: 100px; 10 background: blue; 11 position: absolute; 12 } 13 </style> 14 <script type="text/javascript"> 15 16 document.onmousemove = function(ev) { 17 18 var myDivNode = document.getElementById("myDiv"); 19 var oEvent = ev || event; 20 var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft; 21 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; 22 23 myDivNode.style.left = oEvent.clientX + scrollLeft + "px"; 24 myDivNode.style.top = oEvent.clientY + scrollTop + "px"; 25 26 }; 27 28 </script> 29 </head> 30 31 <body style="height:2000px;"> 32 33 <div id="myDiv"></div> 34 35 </body> 36 </html>
***万事万物都有裂痕,那是光照进来的地方***

浙公网安备 33010602011771号