function getAbsolutePosition(o){//获取对象的绝对位置 var p={x:o.offsetRight,y:o.offsetTop}; while(o=o.offsetParent){ p.x+=o.offsetRight;p.y+=o.offsetTop; } return p; } function showPopUp(){// var p=getAbsolutePosition(this),popDV=document.getElementById('popDV');
popDV.style.top=p.y+'px'; popDV.style.display='block'; } var mouseOutTimer=false;
//window.onload=function(){//加载完毕后给a标签添加事件 function shou(){ var as=document.getElementById('dvCT').getElementsByTagName('span'); for(var i=0;i<as.length;i++){ as[i].onmouseover=showPopUp; } } function hide(e){ var dv=document.getElementById('popDV'); if(e===true)dv.style.display='none';//计时器直接隐藏 else{//如果鼠标从弹出层移出时, var refObj=e.toElement||e.relatedTarget; if(!dv.contains(refObj))dv.style.display='none';//不是div的子控件则隐藏 }
看看页面源码,AJAX获取相关数据
加载时动画显示
解析 。
email:[email protected]
function getAbsolutePosition(o){//获取对象的绝对位置
var p={x:o.offsetRight,y:o.offsetTop};
while(o=o.offsetParent){
p.x+=o.offsetRight;p.y+=o.offsetTop;
}
return p;
} function showPopUp(){//
var p=getAbsolutePosition(this),popDV=document.getElementById('popDV');
popDV.style.top=p.y+'px';
popDV.style.display='block';
}
var mouseOutTimer=false;
//window.onload=function(){//加载完毕后给a标签添加事件
function shou(){
var as=document.getElementById('dvCT').getElementsByTagName('span');
for(var i=0;i<as.length;i++){
as[i].onmouseover=showPopUp;
}
}
function hide(e){
var dv=document.getElementById('popDV');
if(e===true)dv.style.display='none';//计时器直接隐藏
else{//如果鼠标从弹出层移出时,
var refObj=e.toElement||e.relatedTarget;
if(!dv.contains(refObj))dv.style.display='none';//不是div的子控件则隐藏
}
}
if(typeof HTMLElement!='undefined')HTMLElement.prototype.contains=function(o){//扩展非IE浏览器下的contains方法
if(this==o)return true;
while(o=o.parentNode)if(o==this)return true;
return false;
}
</script>GridView 里面 <asp:TemplateField HeaderText="编号">
<ItemTemplate>
<span onmousemove="shou()">
<%# Eval("Id")%></span>
</ItemTemplate>
<ItemStyle CssClass="" Width="7%" />
</asp:TemplateField>
后台 protected void getAllDate_RowDataBound(object sender, GridViewRowEventArgs e)
{ if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ededed';show('" + DataBinder.Eval(e.Row.DataItem, "CertificateID").ToString() + "');p1('" + DataBinder.Eval(e.Row.DataItem, "PrimaryAppearance").ToString() + "');p2(" + DataBinder.Eval(e.Row.DataItem, "PrimaryWeight").ToString() + ");p3('" + DataBinder.Eval(e.Row.DataItem, "PrimaryNeatness").ToString() + "');p4('" + DataBinder.Eval(e.Row.DataItem, "PrimaryColor").ToString() + "');p5('" + DataBinder.Eval(e.Row.DataItem, "PrimaryTurner").ToString().Substring(1, 2) + "');p6('" + DataBinder.Eval(e.Row.DataItem, "PrimaryTurner").ToString().Substring(3, 2) + "');p7('" + DataBinder.Eval(e.Row.DataItem, "PrimaryTurner").ToString().Substring(4, 2) + "');p8('" + DataBinder.Eval(e.Row.DataItem, "PrimaryTurner").ToString() + "');p9('" + DataBinder.Eval(e.Row.DataItem, "SalePrice").ToString() + "')");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); } }