要求,类似商业网站右边的悬浮广告或者咨询客服,点击一下就进入了咨询窗口或者QQ聊天窗口。
网页右侧浮动DIV层广告或在线客服图片框最佳代码
ASP.NET+IE8测试通过.修改都可以大同小异。
<!--请将以下这段代码放到网页中您想要显示固定图标的位置-->
<div id="FloatDIV" style="position: absolute;top: 0px; border-right: activeborder 1px solid; border-top: activeborder 1px solid; border-left: activeborder 1px solid; border-bottom: activeborder 1px solid; z-index:9999">
这里放置浮动层的内容,可以放图片或在线咨询客服的相关东西.
</div>
<div id="showservicepeople" class="showservicepeople" onclick="showservicepeople()">
</div>
<!--可以引用CSS样式和布局-->
<script type="text/javascript">
var MarginLeft = 10; //浮动层离浏览器右侧的距离
var MarginTop = 190; //浮动层离浏览器顶部的距离
var Width = 20; //浮动层宽度
var Heigth= 85; //浮动层高度
//设置浮动层宽、高
function Set()
{
document.getElementById("FloatDIV").style.width = Width + 'px';
document.getElementById("FloatDIV").style.height = Heigth + 'px';
}
//实时设置浮动层的位置
function Move()
{
var b_top = window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
var b_width= document.body.clientWidth;
document.getElementById("FloatDIV").style.top = b_top + MarginTop + 'px';
document.getElementById("FloatDIV").style.left = b_width - Width - MarginLeft + 'px';
setTimeout("Move();",100);
}
function showservicepeople()
{
location.href='在线客服.aspx';
}
Set();
Move();
</script>