62,046
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<script language="javascript" type="text/javascript">
function followcursor(){
var DIV = document.getElementById('div01');
DIV.style.display = "block";
DIV.style.left=document.body.scrollLeft+event.clientX+10
DIV.style.top=document.body.scrollTop+event.clientY+10
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="width: 300px; height: 300px; border: solid 1px #ccc; display: none;position:absolute;"
id="div01">
跟随鼠标显示的DIV<a href="javascript:void(0)" onclick="document.getElementById('div01').style.display='none';">关闭</a>
</div>
<div>
<a href="javascript:void(0)" onclick="followcursor();">点一</a></div>
<div style="position: absolute; top: 300px; left: 400px;">
<a href="javascript:void(0)" onclick="followcursor();">点二</a></div>
</form>
</body>
</html>