IE与FF中获取鼠标坐标
View Code
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head runat="server"> 3 <title></title> 4 <script language="javascript" type="text/javascript"> 5 function Show(obj) { 6 /* 7 *window.event 8 *IE:有window.event对象 9 *FF:没有window.event对象。可以通过给函数的参数传递event对象。如onmousemove=doMouseMove(event) 10 *鼠标当前坐标 11 *IE:event.x和event.y 12 *FF:event.pageX和event.pageY。 13 *通用:两者都有event.clientX和event.clientY属性。 14 */ 15 if(navigator.appName=="Netscape"){ 16 obj.onmousemove=function(event){ 17 if(event.pageX>100 || event.pageY>60){ 18 document.getElementById("abc").style.display = "none"; 19 }else{ 20 return; 21 } 22 } 23 }else{ 24 if(event.offsetX>100 || event.offsetY>60){ 25 document.getElementById("abc").style.display = "none"; 26 } 27 } 28 } 29 function BtnClick(){ 30 document.getElementById("abc").style.display = ""; 31 32 } 33 34 function netscapeMouseMove(e) { 35 if (e.screenX != document.test.x.value && e.screenY != document.test.y.value); 36 { 37 document.test.x.value = e.screenX; 38 document.test.y.value = e.screenY; 39 } 40 } 41 function micro$oftMouseMove() { 42 if (window.event.x != document.test.x.value && window.event.y != document.test.y.value); 43 { 44 document.test.x.value = window.event.x; 45 document.test.y.value = window.event.y; 46 } 47 } 48 </script> 49 </head> 50 <body> 51 <form id="form1" runat="server"> 52 <div style="border:1px solid black;" onMousemove="Show(this);" > 53 <div id="abc" style="width:100px; height:60px;display:none; "> 54 <table style="border:solid 1px #888888; width:100px; height:50px; text-align:center;"> 55 <tr> 56 <td> 57 <a href="#">123</a> 58 </td> 59 </tr> 60 </table> 61 </div> 62 <input id="btn" onclick="BtnClick();" type="button" value="OK" /> 63 </div> 64 </form> 65 </body> 66 <html>