自动弹出对话框的QQ在线客服系统代码.docx
- 文档编号:6450062
- 上传时间:2023-01-06
- 格式:DOCX
- 页数:15
- 大小:42.53KB
自动弹出对话框的QQ在线客服系统代码.docx
《自动弹出对话框的QQ在线客服系统代码.docx》由会员分享,可在线阅读,更多相关《自动弹出对话框的QQ在线客服系统代码.docx(15页珍藏版)》请在冰豆网上搜索。
自动弹出对话框的QQ在线客服系统代码
网站上自动自动弹出对话框的QQ在线客服系统,有点类似于一些在线客服系统,用户打开网站后,会跳出一个窗口,如下图:
同样,要实现这个功能也很简单,我们可以用Js来实现,现在南昌网站建设公司智网互联就给大家详细的介绍Js代码的写法和如何实现这一功能。
首先是介绍JS文件的写法,先建一个JS文件夹,把下面的代码复制命名为:
KF.js
varonline=newArray();
varurlroot="images/";
vartOut=-1;
vardrag=false;
varg_safeNode=null;
lastScrollY=0;
varkfguin;
varws;
varcompanyname;
varwelcomeword;
vartype;
if(kfguin)
{
rightDivHtml=' absolute;top: 160px;right: 1px;">'; rightDivHtml+=kf_getPopupRightDivHtml(kfguin,ws); rightDivHtml+='
document.write(rightDivHtml);
if(type==1&&kf_getCookie('hasshown')==0)
{
companyname=companyname.substr(0,15);
welcomeword=kf_processWelcomeword(welcomeword);
kfguin=kf_getSafeHTML(kfguin);
companyname=kf_getSafeHTML(companyname);
welcomeword=welcomeword.replace(/
welcomeword=kf_getSafeHTML(welcomeword);
welcomeword=welcomeword.replace(/\r/g,"").replace(/\n/g,"
");
window.setTimeout("kf_sleepShow()",2000);
//kf_sleepShow();
}
window.setTimeout("kf_moveWithScroll()",1);
//window.setInterval("wpa_count()",10000);
}
functionkf_getSafeHTML(s)
{
varhtml="";
varsafeNode=g_safeNode;
if(!
safeNode)
{
safeNode=document.createElement("TEXTAREA");
}
if(safeNode)
{
safeNode.innerText=s;
html=safeNode.innerHTML;
safeNode.innerText="";
g_safeNode=safeNode;
}
returnhtml;
}
functionkf_moveWithScroll()
{
if(typeofwindow.pageYOffset!
='undefined'){
nowY=window.pageYOffset;
}
elseif(typeofpatMode!
='undefined'&&patMode!
='BackCompat'){
nowY=document.documentElement.scrollTop;
}
elseif(typeofdocument.body!
='undefined'){
nowY=document.body.scrollTop;
}
percent=.1*(nowY-lastScrollY);
if(percent>0)
{
percent=Math.ceil(percent);
}
else
{
percent=Math.floor(percent);
}
document.getElementById("rightDiv").style.top=parseInt(document.getElementById("rightDiv").style.top)+percent+"px";
if(document.getElementById("kfpopupDiv"))
{
document.getElementById("kfpopupDiv").style.top=parseInt(document.getElementById("kfpopupDiv").style.top)+percent+"px";
}
lastScrollY=lastScrollY+percent;
tOut=window.setTimeout("kf_moveWithScroll()",1);
}
functionkf_hide()
{
if(tOut!
=-1)
{
clearTimeout(tOut);
tOut=-1;
}
document.getElementById("rightDiv").style.visibility="hidden";
}
functionkf_hidekfpopup()
{
if(tOut!
=-1)
{
clearTimeout(tOut);
tOut=-1;
}
document.getElementById("kfpopupDiv").style.visibility="hidden";
tOut=window.setTimeout("kf_moveWithScroll()",1);
}
functionkf_getPopupDivHtml(kfguin,reference,companyname,welcomeword)
{
vartemp='';
temp+=' left;height: 150px;width: 8px;background-image: url('+urlroot+'bg_1.gif);">
temp+=' Tahoma;text-align: left;float: left;height: 150px;width: 324px;background-image: url('+urlroot+'bg_2.gif);background-repeat: repeat-x;">'; temp+=' left;font-size: 14px;color: #FFFFFF;margin: 0px;padding: 10px013px2px;line-height: 17px;">'+companyname+' url('+urlroot+'close.gif);float: right;height: 19px;width: 42px;"onmouseover="javascript: this.style.backgroundPosition=\'bottom\'"onmouseleave="javascript: this.style.backgroundPosition=\'top\'">
temp+=' 83px;padding: 0002px;clear: both;">'; temp+=' url('+urlroot+'face.jpg);height: 70px;width: 70px;float: left;">
temp+=' Tahoma;font-size: 12px;line-height: 24px;width: 240px;margin: 0px;padding: 00012px;display: block;float: left;margin-top: 2px;word-wrap: break-word;">'+welcomeword+'
temp+=' both;">'; temp+=' right;background-image: url('+urlroot+'btn_1.gif);margin: 0005px;padding: 0px;border: 0px;height: 21px;width: 69px;">'; temp+=' (1)"href="#"style="float: right;background-image: url('+urlroot+'btn_2.gif);margin: 0px;padding: 0px;border: 0px;height: 21px;width: 69px;">