脚本代码
function Show(sea, comment)
{
//获得鼠标的X轴的坐标
x = event.clientX + document.body.scrollLeft ;
//获得鼠标的Y轴的坐标
y = event.clientY + document.body.scrollTop ;
//显示弹出窗体
Popup.style.display="block";
//设置窗体的X,Y轴的坐标
Popup.style.left = x;
Popup.style.top = y;
document.getElementById("td1").innerText="缺勤人员及原因:"+sea;
document.getElementById("td2").innerText="会议主要内容:"+comment;
}
//隐藏弹出窗体
function Hide()
{
Popup.style.display="none";
}
数据绑定事件
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF';");
e.Item.Attributes.Add("onmousemove", "Show('"+dtab.Rows[e.Item.ItemIndex+(DataGrid1.CurrentPageIndex*DataGrid1.PageSize)]["TeamMeet_AbsentName"].ToString()+"','"
+dtab.Rows[e.Item.ItemIndex+(DataGrid1.CurrentPageIndex*DataGrid1.PageSize)]["TeamMeet_Content"].ToString()+"');");
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor=this.oldcolor;Hide();");
}
}
Popup是层
td1,td2是层里一个table的单元格