经常会在一些网站上看到QQ客服效果,当客服人员在线的时候,网页上的QQ显示为在线状态,不在线的时候,网页上的QQ显示下线状态,这是通过javascript来实现的。
<script language=javascript>
function picsize(obj,MaxWidth){
img=new Image();//新建一个Image对象,用这个对象的width就不会出现width为0的现象
img.src="/fk/blog/obj.src";
if (img.width>MaxWidth)
{
return MaxWidth;
}
else
{
return img.width;
}
}
</script>
<style>
<!--
div {font-size:12px;}
-->
</style>
</head>
<body>
<SCRIPT>
var online= new Array();
if (!document.layers)
document.write('<div id="divStayTopLeft" style="position:absolute">')
</SCRIPT>
<layer id="divStayTopLeft">
<table border="0" width="110" cellspacing="0" cellpadding="0">
<tr><td width="110"><img border=0 src="images/up5.gif"></td></tr>
<script src="http://webpresence.qq.com/getonline?Type=1&391193603:471133041:"></script><!--设置两个QQ号码,分别对应下面两个-->
<tr><td valign=middle background="images/mid5.gif">
<script>
if (online[0]==0)
document.write(" <div align=center><img src=\"images/qqoff5.gif\" border=0 align=middle><a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=391193603&Site=在线咨询& Menu=no' title='客服不在线,请留言'>技术员</a></div>");
else
document.write(" <div align=center><img src=\"images/qqon5.gif\" border=0 align=middle><a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=391193603&Site=在线咨询&Menu= no' title='在线即时交谈'>技术员</a></div>");
</script>
</td></tr>
<tr><td valign=middle background="images/mid5.gif">
<script>
if (online[1]==0)
document.write(" <div align=center><img src=\"images/qqoff5.gif\" border=0 align=middle><a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=471133041&Site=在线咨询& Menu=no' title='客服不在线,请留言'>客&nbsp;&nbsp;服</a></div>");
else
document.write(" <div align=center><img src=\"images/qqon5.gif\" border=0 align=middle><a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=471133041&Site=在线咨询&Menu= no' title='在线即时交谈'>客&nbsp;&nbsp;服</a></div>");
</script>
</td></tr>
<tr><td width="110"><img border=0 src="images/down5.gif"></td></tr>
</table>
<script type="text/javascript">
//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"
if (!document.layers)
document.write('</div>')
function JSFX_FloatTopDiv()
//more javascript:http://www.webjx.com
{
var startX =6,
startY = 150;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();
</script>
<br>
<br>
<br>
<br>
</body>
</html>