JS Imitation QQ customer Service source code

Source: Internet
Author: User
Tags abs visibility

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Online customer service code that can automatically eject information </title>

&lt;body style= "Text-align:center" &gt;


&lt;script type=text/Web page special effects &gt;kfguin= "123456789"; ws= ""; Companyname= "111cn.net"; welcomeword= "Hello, welcome &lt;brt&gt; excuse me, is there anything I can do for you?" Type= "1";&lt;/script&gt;


&lt;script src= "Js/kf.js" type=text/javascript&gt;&lt;/script&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt; function: Can scroll with the scroll bar, can move the window, after n seconds can automatically eject the information. &lt;/p&gt;


&lt;p&gt; Use Method:&lt;/p&gt;


&lt;p&gt;1 kfguin=&amp;quot; Replacement QQ number &amp;quot;; Ws=&amp;quot;&lt;a href= "Http://www.111cn.net" &gt;www.111cn.net&lt;/a&gt;&amp;quot;; companyname=&amp;quot;&amp;quot;; &lt;/p&gt;


&lt;p&gt;2 If you want to modify the Window.settimeout (&amp;quot;kf_sleeps tutorial How () &amp;quot;,2000) under the pop-up time kf.js; Conversion unit of 2000 equals 2 seconds &lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;/body&gt;


&lt;/html&gt;

The Kf.js file code is as follows

var online= new Array ();
var urlroot = "images/";
var tout =-1;
var drag = false;
var g_safenode = null;
lastscrolly = 0;
var Kfguin;
var ws;
var CompanyName;
var Welcomeword;
var type;

if (Kfguin)
{
rightdivhtml = ' <div id= ' rightdiv ' style= ' position:absolute; top:160px; right:1px; " > ';

Rightdivhtml + + kf_getpopuprightdivhtml (KFGUIN,WS);





rightdivhtml + = ' &lt;/div&gt; ';





document.write (rightdivhtml);





if (type==1 &amp;&amp; kf_getcookie (' Hasshown ') ==0)


{


CompanyName = Companyname.substr (0,15);


Welcomeword = Kf_processwelcomeword (Welcomeword);





Kfguin = kf_getsafehtml (Kfguin);


CompanyName = kf_getsafehtml (COMPANYNAME);





Welcomeword = Welcomeword.replace (/&lt;brt&gt;/g, ' RN ');


Welcomeword = kf_getsafehtml (Welcomeword);


Welcomeword = Welcomeword.replace (/r/g, ""). Replace (/n/g, "&lt;br&gt;");





Window.settimeout ("Kf_sleepshow ()", 2000);


Kf_sleepshow ();


}


Window.settimeout ("Kf_movewithscroll ()", 1);


Window.setinterval ("Wpa_count ()", 10000);


}

function kf_getsafehtml (s)
{
var html = "";
var safenode = G_safenode;

if (!safenode)
{
Safenode = document.createelement ("textarea");
}

if (Safenode)
{
Safenode.innertext = s;
html = safenode.innerhtml;
Safenode.innertext = "";

G_safenode = Safenode;
}

return HTML;
}

function Kf_movewithscroll ()
{
if (typeof window.pageyoffset!= ' undefined ') {
Nowy = Window.pageyoffset;
}
else if (typeof document.compatmode!= ' undefined ' && document.compatmode!= ' Backcompat ') {
Nowy = Document.documentelement.scrolltop;
}
else if (typeof document.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);
}

function Kf_hide ()
{
if (tout!=-1)
{
Cleartimeout (Tout);
Tout=-1;
}
document.getElementById ("Rightdiv"). Style.visibility = "hidden";
}

function Kf_hidekfpopup ()
{
if (tout!=-1)
{
Cleartimeout (Tout);
Tout=-1;
}
document.getElementById ("Kfpopupdiv"). Style.visibility = "hidden";
Tout=window.settimeout ("Kf_movewithscroll ()", 1);
}

function kf_getpopupdivhtml (Kfguin,reference,companyname,welcomeword)


{


var temp = ';


Temp + = ' &lt;div style= ' float:left;height:150px;width:8px;background-image:url (' +urlroot+ ' bg_1.gif); " &gt;&lt;/div&gt; ';


Temp + = ' &lt;div style= ' font-family:tahoma;text-align:left;float:left;height:150px;width:324px;background-image: URL (' +urlroot+ ' bg_2.gif); background-repeat:repeat-x; " &gt; ';


temp = ' &lt;div&gt;&lt;h1 style= ' float:left;font-size:14px;color: #ffffff; margin:0px;padding:10px 0 13px 2px;line-he ight:17px; " &gt; ' +companyname+ ' &lt;/h1&gt;&lt;a href= ' # "onclick=" Kf_hidekfpopup (); return false; "style=" Background-image:url ( ' +urlroot+ ' close.gif); float:right;height:19px;width:42px; "Onmouseo tutorial ver=" javascript: this.style.backgroundposition= ' Bottom ' "onmouseleave=" javascript:this.style.backgroundposition= ' top ' "&gt;&lt;/a &gt;&lt;/div&gt; ';


temp = ' &lt;div style= ' height:83px;padding:0 0 0 2px;clear:both; &gt; ';


temp = ' &lt;div style= ' background-image:url (' +urlroot+ ' face.jpg); height:70px;width:70px;float:left; " &gt;&lt;/div&gt; ';


temp = ' &lt;p style= ' font-family:tahoma;font-size:12px;line-height:24px;width:240px;margin:0px;padding:0 0 0 12px; Display:block;float:left;margin-top:2px;word-wrap:break-word; " &gt; ' +welcomeword+ ' &lt;/p&gt;&lt;/div&gt; ';


temp = ' &lt;div style= ' clear:both; &gt; ';


temp = ' &lt;a onclick= ' kf_hidekfpopup (); return false; "href=" # "style=" Float:right;background-image:url (' +urlroot+ ') btn_1.gif); margin:0 0 0 5px;padding:0px;border:0px;height:21px;width:69px; " &gt;&lt;/a&gt; ';


temp = ' &lt;a onclick= ' Kf_openchatwindow (1) "href=" # "style=" Float:right;background-image:url (' +urlroot+ ' btn_2.gif ); margin:0px;padding:0px;border:0px;height:21px;width:69px; " &gt;&lt;/a&gt;&lt;/div&gt; ';


temp = ' &lt;/div&gt;&lt;div style= ' float:left;height:150px;width:8px;background-image:url (' +urlroot+ ' bg_1.gif); Background-position:right; " &gt;&lt;/div&gt; ';

return temp;
}

function kf_getpopuprightdivhtml (kfguin,reference)
{
var temp = "";

temp = ' &lt;div class= ' Wpa_popup "style=" width:90px; height:150px; " &gt; ';


Temp + = ' &lt;div style= ' width:8px; height:150px; Float:left; Background:url (' +urlroot+ ' bg_1.gif); " &gt;&lt;/div&gt; ';


Temp + = ' &lt;div style= ' float:left; width:74px; height:150px; Background:url (' +urlroot+ ' middle.jpg); Background-position:center; " &gt; ';


temp = ' &lt;div &gt;&lt;h1 style= ' line-height:17px; font-size:14px; Color: #fff; margin:0px; padding:10px 0 13px 8px; " &gt;&amp;nbsp;&lt;/h1&gt;&lt;/div&gt; ';


Temp + = ' &lt;div style= ' height:83px; padding:0 0 0 2px; Clear:both; " &gt;&lt;div style= "width:70px; height:70px; Float:left; Background:url (' +urlroot+ ' face.jpg); " &gt;&lt;/div&gt;&lt;/div&gt; ';


temp = ' &lt;div style= ' clear:both; &gt;&lt;a href= "#" onclick= "Kf_openchatwindow (0)" style= "WIDTH:69PX; height:21px; Background:url (' +urlroot+ ' btn_2.gif); margin:0 0 0 2px; Display:block; " &gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt; ';


Temp + = ' &lt;div style= ' width:8px; height:150px; Float:left; Background:url (' +urlroot+ ' bg_1.gif) right; " &gt;&lt;/div&gt;&lt;/div&gt; ';

return temp;
}

Added by Simon 2008-11-04
function Kf_openchatwindow (flag)
{
window.open (' http://bizapp.qq.com/webc.htm?new=0&amp;sid= ' +kfguin+ ' &amp;o=&amp;q=7 ', ' _blank ', ' height=544, Width=644,toolbar=no,scrollbars=no,menubar=no,status=no ');
if (flag==1)
{
Kf_hidekfpopup ();
}
return false;
}
Added by Simon 2008-11-04 end

function Kf_validatewelcomeword (Word)


{


var count = 0;





for (Var i=0;i&lt;word.length;i++)


{


if (Word.charat (i) = = ' n ')


{


count++;


}


if (count&gt;2)


{


return 2;


}


}


if (Word.length &gt; 57+2*count)


{


return 1;


}





Count = 0;


var temp = Word.indexof (' n ');


while (Temp!=-1)


{


Word = Word.substr (temp+1);


if (temp-1&lt;=19)


{


Count + 19;


}


else if (temp-1&lt;=38)


{


Count + 38;


}


else if (temp-1&lt;=57)


{


Count + 57;


}





temp = Word.indexof (' n ');


}


Count+=word.length;


if (count&gt;57)


{


return 3;


}





return 0;


}

function Kf_processwelcomeword (Word)
{
Word = Word.substr (0,57+10);
var result = ';
var count = 0;
var temp = word.indexof (' <brt> ');

while (count<57 && temp!=-1)
{

if (temp&lt;=19)


{


Count + 19;


if (count&lt;=57)


{


result = Word.substr (0,temp+5);


}


Else


{


result = Word.substr (0,57-count&gt;word.length?word.length:57-count);


}


}


else if (temp&lt;=38)


{


Count + 38;


if (count&lt;=57)


{


result = Word.substr (0,temp+5);


}


Else


{


result = Word.substr (0,57-count&gt;word.length?word.length:57-count);


}


}


else if (temp&lt;=57)


{


Count + 57;


if (count&lt;=57)


{


result = Word.substr (0,temp+5);


}


Else


{


result = Word.substr (0,57-count&gt;word.length?word.length:57-count);


}


}





Word = Word.substr (temp+5);


temp = Word.indexof (' &lt;brt&gt; ');


}





if (count&lt;57)


{


result = Word.substr (0,57-count&gt;word.length?word.length:57-count);


}





return result;


}

function Kf_setcookie (name, value, exp, path, domain)
{
var NV = name + "=" + Escape (value) + ";";

var d = null;
if (typeof (exp) = = "Object")
{
D = exp;
}
else if (typeof (exp) = "number")
{
D = new Date ();
D = new Date (D.getfullyear (), D.getmonth (), D.getdate (), d.gethours (), d.getminutes () + exp, d.getseconds (), d.getmillise Conds ());
}

if (d)
{
NV + = "expires=" + d.togmtstring () + ";";
}

if (!path)
{
NV = "path=/;";
}
else if (typeof (path) = = "string" && path!= "")
{
NV + = "Path=" + path + ";";
}

if (!domain && typeof (VS_COOKIEDM)!= "undefined")
{
domain = VS_COOKIEDM;
}

if (typeof (Domain) = "string" && domain!= "")
{
NV + + "domain=" + domain + ";";
}

Document.cookie = NV;
}

function Kf_getcookie (name)
{
var value = "";
var cookies = Document.cookie.split (";");
var NV;
var i;

for (i = 0; i < cookies.length; i++)
{
NV = cookies[i].split ("=");

if (NV && nv.length >= 2 && name = = Kf_rtrim (Kf_ltrim (nv[0)))
{
Value = unescape (nv[1]);
}
}

return value;
}

function Kf_sleepshow ()
{
Kf_setcookie (' Hasshown ', 1, ', '/', ' bizapp.qq.com ');

var position = parseint (document.getElementById ("Rightdiv"). Style.top) + 170;
popupdivhtml = ' <div id= ' kfpopupdiv ' onmousedown= ' mymove.move (' Kfpopupdiv ', event,1); " Style= "Z-index:10000;filter:alpha (opacity=90);p Osition:absolute; Top: ' +position+ ' px; Right:500px;color: #000; font-size:12px;cursor:move;height:150px;width:340px; " > ';
Popupdivhtml + + kf_getpopupdivhtml (Kfguin,ws,companyname,welcomeword);
popupdivhtml + = ' </div> ';
Document.body.insertadjacenthtml ("BeforeEnd", popupdivhtml);
}

function Kf_dealerrors ()
{
Kf_hide ();
return true;
}

function Kf_ltrim (str)
{
while (Str.charat (0) = = "")
{
str = str.slice (1);
}
return str;
}

function Kf_rtrim (str)
{
var ilength = str.length;
while (Str.charat (ilength-1) = "")
{
str = str.slice (0, ilength-1);
ilength--;
}
return str;
}

Window.onerror = kf_dealerrors;
var mymove = new Tong_movediv ();

function Tong_movediv ()


{


This.move=function (id,evt,t)


{


if (id = = "")


{


Return


}


var o = document.getElementById (ID);


if (!o)


{


Return


}


EVT = evt? Evt:window.event;


O.style.position = "absolute";


O.style.zindex = 200;


var obj = evt.srcelement? Evt.srcelement:evt.target;


var w = o.offsetwidth;


var h = o.offsetheight;


var L = o.offsetleft;


var t = o.offsettop;


var div = document.createelement ("div");


Document.body.appendchild (DIV);


Div.style.css Tutorial Text = "Filter:alpha (opacity=10,style=0); Opacity:0.2;width:" +w+ "Px;height:" +h+ "Px;top:" +t+ "PX; Left: "+l+" Px;position:absolute;background: #000 ";


Div.setattribute ("id", ID + "temp");


This.move_onlymove (id,evt,t);


}





This.move_onlymove = function (id,evt,t)


{


var o = document.getElementById (id+ "temp");


if (!o)


{


Return


}


EVT = evt?evt:window.event;


var relleft = Evt.clientx-o.offsetleft;


var reltop = evt.clienty-o.offsettop;


if (!window.captureevents)


{


O.setcapture ();


}


Else


{


Window.captureevents (Event.mousemove|event.mouseup);


}





Document.onmousemove = function (e)


{


if (!o)


{


Return


}


E = e? E:window.event;





var bh = Math.max (document.body.scrollheight,document.body.clientheight,document.body.offsetheight,


Document.documentelement.scrollheight,document.documentelement.clientheight, Document.documentelement.offsetheight);


var bw = Math.max (Document.body.scrollwidth,document.body.clientwidth,document.body.offsetwidth,


Document.documentelement.scrollwidth,document.documentelement.clientwidth,document.documentelement.offsetwidth );


var SBW = 0;


if (Document.body.scrollwidth &lt; BW)


SBW = Document.body.scrollwidth;


if (Document.body.clientwidth &lt; bw &amp;&amp; SBW &lt; document.body.clientwidth)


SBW = document.body.clientwidth;


if (Document.body.offsetwidth &lt; bw &amp;&amp; SBW &lt; document.body.offsetwidth)


SBW = Document.body.offsetwidth;


if (Document.documentelement.scrollwidth &lt; bw &amp;&amp; SBW &lt; Document.documentelement.scrollwidth)


SBW = Document.documentelement.scrollwidth;


if (Document.documentelement.clientwidth &lt; bw &amp;&amp; SBW &lt; Document.documentelement.clientwidth)


SBW = Document.documentelement.clientwidth;


if (Document.documentelement.offsetwidth &lt; bw &amp;&amp; SBW &lt; Document.documentelement.offsetwidth)


SBW = Document.documentelement.offsetwidth;





if (e.clientx-relleft &lt;= 0)


{


O.style.left = 0 + "px";


}


else if (e.clientx-relleft &gt;= bw-o.offsetwidth-2)


{


O.style.left = (sbw-o.offsetwidth-2) + "px";


}


Else


{


O.style.left = e.clientx-relleft + "px";


}


if (e.clienty-reltop &lt;= 1)


{


O.style.top = 1 + "px";


}


else if (e.clienty-reltop &gt;= bh-o.offsetheight-30)


{


O.style.top = (bh-o.offsetheight) + "px";


}


Else


{


O.style.top = e.clienty-reltop + "px";


}


}





Document.onmouseup = function ()


{


if (!o) return;





if (!window.captureevents)


{


O.releasecapture ();


}


Else


{


Window.releaseevents (Event.mousemove|event.mouseup);


}





var O1 = document.getElementById (ID);


if (!O1)


{


Return


}


var l0 = O.offsetleft;


var t0 = o.offsettop;


var L = o1.offsetleft;


var t = o1.offsettop;





Alert (L0 + "" + t0 + "" + L + "" +t);





Mymove.move_e (ID, L0, t0, L, t,t);


Document.body.removechild (o);


o = null;


}


}








This.move_e = function (ID, l0, t0, L, t,t)


{


if (typeof (window["CT" + id])!= "undefined")


{


Cleartimeout (window["CT" + id]);


}





var o = document.getElementById (ID);


if (!o) return;


var SL = st = 8;


var s_l = Math.Abs (l0-l);


var s_t = Math.Abs (T0-T);


if (s_l-s_t &gt; 0)


{


if (s_t)


{


SL = Math.Round (s_l/s_t) &gt; 8? 8:math.round (s_l/s_t) * 6;


}





Else


{


SL = 0;


}


}


Else


{


if (s_l)


{


st = Math.Round (s_t/s_l) &gt; 8? 8:math.round (s_t/s_l) * 6;


}


Else


{


st = 0;


}


}





if (L0-l &lt; 0)


{


SL *=-1;


}


if (T0-t &lt; 0)


{


St *=-1;


}


if (Math.Abs (L + sl-l0) &lt; &amp;&amp; SL)


{


SL = SL &gt; 0? 2:-2;


}


if (Math.Abs (t + st-t0) &lt; &amp;&amp; St)


{


st = st &gt; 0? 2:-2;


}


if (Math.Abs (L + sl-l0) &lt; &amp;&amp; SL)


{


SL = SL &gt; 0? 1:-1;


}


if (Math.Abs (t + st-t0) &lt; &amp;&amp; St)


{


st = st &gt; 0? 1:-1;


}


if (s_l = = 0 &amp;&amp; s_t = 0)


{


Return


}


if (t)


{


O.style.left = l0 + "px";


O.style.top = t0 + "px";


Return


}


Else


{


if (Math.Abs (L + sl-l0) &lt; 2)


{


O.style.left = l0 + "px";


}


Else


{


O.style.left = l + SL + "px";


}


if (Math.Abs (t + st-t0) &lt; 2)


{


O.style.top = t0 + "px";


}


Else


{


O.style.top = t + st + "px";


}





window["CT" + id] = Window.settimeout ("mymove.move_e (' + ID +" ', "+ L0 +", "+ t0 +", "+ (L + SL) +", "+ (T + st) +", "+t+") ", 1);


}


}


}


function Wpa_count ()


{


var BODY = document.getelementsbytagname (' body '). Item (0);


var img = document.createelement (' img ');


var now = new Date ();


IMG.SRC = "http://bizapp.qq.com/cgi/wpac?kfguin=" + Kfguin + "&amp;ext=0" + "&amp;time=" + now.gettime () + "ip=172.23.30.1" 5&amp; ";


Img.style.display = "None";


Body.appendchild (IMG);


}

SOURCE Download Address:

Http://down.111cn.net/down/code/js/zaixiankefu/2011/0306/22843.html

Effect Preview Address:

http://upload.111cn.net/110306/tipkf/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.