62,041
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" EnableViewState="true" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body id="b" runat="server">
<form id="form1" runat="server">
<script type="text/javascript">
function Init(txtId) {
d = document.createElement("div");
d.style.position = "absolute";
d.style.display = "none";
d.id = "d" + txtId;
d.style.backgroundColor = "orange";
document.body.appendChild(d);
document.getElementById(txtId).onkeydown = Show;
document.getElementById(txtId).onblur = Hide;
}
function Show(evt) {
ele = window.event ? window.event.srcElement : evt.target;
d = document.getElementById("d" + ele.id);
d.style.display = "";
d.innerHTML = "xxxcccccccccc";
d.style.top = ele.offsetTop + ele.offsetHeight + "px";
d.style.left = ele.offsetLeft + "px";
d.style.width = ele.offsetWidth + "px";
}
function Hide(evt) {
ele = window.event ? window.event.srcElement : evt.target;
d = document.getElementById("d" + ele.id);
d.style.display = "none";
d.innerHTML = "";
}
</script>
<asp:TextBox ID="TextBox1" runat="server" Width="320px"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Width="320px"></asp:TextBox>
</form>
<script type="text/javascript">
window.onload = function () {
Init("<%=TextBox1.ClientID %>");
Init("<%=TextBox2.ClientID %>");
}
</script>
</body>
</html>
<%@ Page Language="C#" EnableViewState="true" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body id="b" runat="server">
<form id="form1" runat="server">
<script type="text/javascript">
function Init(txtId) {
d = document.createElement("div");
d.style.position = "absolute";
d.style.display = "none";
d.id = "d" + txtId;
d.style.backgroundColor = "orange";
document.body.appendChild(d);
document.getElementById(txtId).onkeydown = Show;
document.getElementById(txtId).onblur = Hide;
txt = document.getElementById(txtId);
t = GetXY(txt)
d.style.top = t.y + txt.offsetHeight + "px";
d.style.left = t.x + "px";
d.style.width = txt.offsetWidth + "px";
}
function Show(evt) {
ele = window.event ? window.event.srcElement : evt.target;
d = document.getElementById("d" + ele.id);
d.style.display = "";
d.innerHTML = "xxxcccccccccc";
}
function Hide(evt) {
ele = window.event ? window.event.srcElement : evt.target;
d = document.getElementById("d" + ele.id);
d.style.display = "none";
d.innerHTML = "";
}
function GetXY(txt) {
var r = { x: txt.offsetLeft, y: txt.offsetTop };
while (txt.offsetParent) {
txt = txt.offsetParent;
r.x += txt.offsetLeft;
r.y += txt.offsetTop;
}
return r;
}
</script>
<asp:TextBox ID="TextBox1" runat="server" Width="320px"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Width="320px"></asp:TextBox>
</form>
<script type="text/javascript">
window.onload = function () {
Init("<%=TextBox1.ClientID %>");
Init("<%=TextBox2.ClientID %>");
}
</script>
</body>
</html>
<%@ Page Language="C#" EnableViewState="true" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body id="b" runat="server">
<form id="form1" runat="server">
<script type="text/javascript">
function Init(txtId) {
d = document.createElement("div");
d.style.position = "absolute";
d.style.display = "none";
d.id = "d" + txtId;
d.style.backgroundColor = "orange";
document.body.appendChild(d);
}
function HideShow(evt, divId, flag) {
d = document.getElementById("d" + divId);
d.style.display = flag;
d.innerHTML = "xxx";
d.style.top = document.getElementById(divId).offsetTop + document.getElementById(divId).offsetHeight + "px";
d.style.left = document.getElementById(divId).offsetLeft + "px";
d.style.width = document.getElementById(divId).offsetWidth + "px";
}
</script>
<asp:TextBox ID="TextBox1" runat="server" Width="320px" onkeydown="HideShow(event,this.id,'')"
onblur="HideShow(event,this.id,'none')"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Width="320px" onkeydown="HideShow(event,this.id,'')"
onblur="HideShow(event,this.id,'none')"></asp:TextBox>
</form>
<script type="text/javascript">
Init("<%=TextBox1.ClientID %>");
Init("<%=TextBox2.ClientID %>");
</script>
</body>
</html>