您的位置:首页 > 编程语言

QQ网页悬浮窗,点击展开的代码

2011-07-19 13:27 573 查看
QQ网页悬浮窗,点击展开的代码,类似QQ在线客服一样,平时会隐藏在网页的右侧,当需要时把鼠标移过去,它就自动展开了,在移走,又恢复了,实用的效果,可以用来制作在线客服。



<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>可展开和收起的在线客服代码</title>
<style type="text/css">
img{border:0;}
ul,li{padding:0;margin:0;}
.QQbox {z-index:99;right:0;width:128px;height:128px;position:absolute;}
.QQbox .press{right:0;width:36px;cursor:pointer;position:absolute;height:128px;}
.QQbox .Qlist{left:0;width:131px;position:absolute;height:128px;background:url(http://www.codefans.net/jscss/demoimg/201107/floatServiceBj.gif) no-repeat left center;}
.QQbox .Qlist ul{padding:43px 0 0 21px;}
.QQbox .Qlist li{height:26px;margin-bottom:11px;_margin-bottom:7px; list-style-type:none;}
</style>
<script type="text/javascript">
window.onload = window.onresize = window.onscroll = function ()
{
var oBox = document.getElementById("divQQbox");
var oLine = document.getElementById("divOnline");
var oMenu = document.getElementById("divMenu");
var iScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
setTimeout(function ()
{
clearInterval(oBox.timer);
var iTop = parseInt((document.documentElement.clientHeight - oBox.offsetHeight)/2) + iScrollTop;
oBox.timer = setInterval(function ()
{
var iSpeed = (iTop - oBox.offsetTop) / 8;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
oBox.offsetTop == iTop ? clearInterval(oBox.timer) : (oBox.style.top = oBox.offsetTop + iSpeed + "px");
}, 30)
}, 100)

oBox.onmouseover = function ()
{
this.style.width = 131 + "px";
oLine.style.display = "block";
oMenu.style.display = "none";
};
oBox.onmouseout = function ()
{
this.style.width = '';
oLine.style.display = "none";
oMenu.style.display = "block";
};
};
</script>
</head>
<body style="height:2000px;">
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<!--在线客服 begin -->
<div class="QQbox" id="divQQbox" >
<div class="Qlist" id="divOnline" style="display:none;">
<ul>
<li><a href="#"><img src="http://www.codefans.net/jscss/demoimg/201107/floatServiceWeb.gif" alt="网页方式"></a></li>
<li><a href="#"><img src="http://www.codefans.net/jscss/demoimg/201107/floatServiceQq.gif" alt="QQ方式"></a></li>
</ul>
</div>
<div id="divMenu"><img src="http://www.codefans.net/jscss/demoimg/201107/floatService.gif" class="press" alt="在线客服"></div>
</div>
</body>
</html>


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: