实现QQ在线咨询(随滚动条滚动)效果步聚
1.新建ASCX用户控件,代码如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QQMenu.ascx.cs" Inherits="FHP.Web.ASCX.QQMenu" %>
<div id="style1" style="position:absolute;left:0px; top:160px; text-align:left; z-index:0">
<table border="0" cellpadding="0" cellspacing="0" width="110">
<tr>
<td width="110" style="background-image: url(../Images/QQTop.gif); width: 110px; height: 30px; text-align: right" valign="bottom">
<asp:LinkButton ID="LinkButton1" title="关闭在线咨询" runat="server" style="margin-bottom:2px; font-size:10px" OnClientClick="document.getElementById('style1').style.display='none';return false;" CssClass="caption_02">关闭</asp:LinkButton>
</td>
</tr>
<tr>
<td background="../Images/QQmiddle.gif"
valign="middle">
<table style="width:95px; margin-left:5px">
<tr>
<td style="width:25px; height:25px"><img border="0" src='../Images/online.gif'/></td>
<td style="text-align: left"><a href="tencent://message/?Uin=245791213&Site=www.luorispace.com&Menu=no"; class="Bottom" title="落日空间|QQ:245791213">
落日空间</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="110" style="background-image: url(../Images/QQBottom.gif); width: 110px; height: 30px; text-align: right" valign="bottom">
</td>
</tr>
</table>
</div>
<script type="text/javascript">
x0=parseInt(style1.style.left);
y0=parseInt(style1.style.top);
function window.onscroll(){
y=document.body.scrollTop;
x=document.body.scrollLeft;
style1.style.top=y0+y;
style1.style.left=x0+x;
}
</script>
2.在ASPX页面调用上面的用户控件
删除ASPX页面中的“<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">“
否则无法实现控件跟随滚动条的效果
1.新建ASCX用户控件,代码如下:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QQMenu.ascx.cs" Inherits="FHP.Web.ASCX.QQMenu" %>
<div id="style1" style="position:absolute;left:0px; top:160px; text-align:left; z-index:0">
<table border="0" cellpadding="0" cellspacing="0" width="110">
<tr>
<td width="110" style="background-image: url(../Images/QQTop.gif); width: 110px; height: 30px; text-align: right" valign="bottom">
<asp:LinkButton ID="LinkButton1" title="关闭在线咨询" runat="server" style="margin-bottom:2px; font-size:10px" OnClientClick="document.getElementById('style1').style.display='none';return false;" CssClass="caption_02">关闭</asp:LinkButton>
</td>
</tr>
<tr>
<td background="../Images/QQmiddle.gif"
valign="middle">
<table style="width:95px; margin-left:5px">
<tr>
<td style="width:25px; height:25px"><img border="0" src='../Images/online.gif'/></td>
<td style="text-align: left"><a href="tencent://message/?Uin=245791213&Site=www.luorispace.com&Menu=no"; class="Bottom" title="落日空间|QQ:245791213">
落日空间</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="110" style="background-image: url(../Images/QQBottom.gif); width: 110px; height: 30px; text-align: right" valign="bottom">
</td>
</tr>
</table>
</div>
<script type="text/javascript">
x0=parseInt(style1.style.left);
y0=parseInt(style1.style.top);
function window.onscroll(){
y=document.body.scrollTop;
x=document.body.scrollLeft;
style1.style.top=y0+y;
style1.style.left=x0+x;
}
</script>
2.在ASPX页面调用上面的用户控件
删除ASPX页面中的“<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">“
否则无法实现控件跟随滚动条的效果