资源描述
自动弹出对话框的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(//g,'\r\n');
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);">
';