<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs" Inherits="Default7" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> <a href="#" οnmοusemοve="setPosition(event,true)" οnmοuseοut="setPosition('',false)">link 1</a><br /> <a href="#" οnmοusemοve="setPosition(event,true)" οnmοuseοut="setPosition('',false)">link 2</a><br /> <a href="#" οnmοusemοve="setPosition(event,true)" οnmοuseοut="setPosition('',false)">link 3</a><br /> <div style="position:absolute;width:100px;height:100px;border:solid 1px red;top:100px;left:100px;display:none;background:#fff" id="div1">i'm here.</div> </div> </form> <script type="text/javascript"> function setPosition(e,isShow){ var oDiv=document.getElementById("div1"); if(isShow){ //为了简单起见,脚本只判断IE与非IE,不多种浏览器之间,可能会有兼容问题,你可以自己完善代码,但是有小小的代价 var isIe=navigator.appName.indexOf("Microsoft")!=-1?true:false; oDiv.style.top=isIe?event.clientY+"px":e.pageY+"px"; var iLeft=isIe?event.clientX:e.pageX; iLeft+=12; oDiv.style.left=iLeft+"px"; if(isShow) oDiv.style.display=""; } else oDiv.style.display="none"; } </script> </body> </html>