Sample Code of online qq customer service on the right side of the webpage

Source: Internet
Author: User

QQ online customer service code on the right side of the webpage

Copy codeThe Code is as follows:
Function myEvent (obj, ev, fn ){
If (obj. attachEvent ){
Obj. attachEvent ('on' + ev, fn );
} Else {
Obj. addEventListener (ev, fn, false );
};
};
Function getbyClass (id, sClass ){
Var oParent = document. getElementById (id );
Var all = oParent. getElementsByTagName ('*');
Var array = [];
For (var I = 0; I <all. length; I ++ ){
If (all [I]. className = sClass ){
Array. push (all [I]);
};
};
Return array;
};
Function getStyle (obj, name ){
If (obj. currentStyle ){
Return obj. currentStyle [name];
} Else {
Return getComputedStyle (obj, false) [name];
};
};
Function Running (obj, json, fnEnd ){
ClearInterval (obj. timer );
Obj. timer = setInterval (function (){
Var now = 0;
Var bStop = true;
For (var attr in json ){
If (attr = 'opacity '){
Now = Math. round (parseFloat (getStyle (obj, attr) * 100 );
} Else {
Now = parseInt (getStyle (obj, attr ));
};
Var speed = (json [attr]-now)/5;
Speed = speed> 0? Math. ceil (speed): Math. floor (speed );
If (now! = Json [attr]) bStop = false;
If (attr = 'opacity '){
Obj. style. filter = 'Alpha (opacity: '+ now + speed + ')';
Obj. style. opacity = (now + speed)/100;
} Else {
Obj. style [attr] = speed + now + 'px ';
};
}
If (bStop ){
ClearInterval (obj. timer );
If (fnEnd) fnEnd ();
}
}, 30 );
}
Function Flexing (obj, json, fnEnd ){
ClearInterval (obj. timer );
Obj. timer = setInterval (function (){
Var now = 0;
Var bStop = true;
For (var attr in json ){
If (! Obj. speed) obj. speed = {};
If (! Obj. speed [attr]) obj. speed [attr] = 0;
Now = parseInt (getStyle (obj, attr ));
If (Math. abs (json [attr]-now)> 1 | Math. abs (obj. speed [attr])> 1 ){
BStop = false;
Obj. speed [attr] + = (json [attr]-now)/5;
Obj. speed [attr] * = 0.85;
Var MaxSpeed = 65;
If (Math. abs (obj. speed [attr])> MaxSpeed ){
Obj. speed [attr] = obj. speed [attr]> 0? MaxSpeed:-MaxSpeed;
};
Obj. style [attr] = now + obj. speed [attr] + 'px ';
};
};
If (bStop ){
ClearInterval (obj. timer );
Obj. style [attr] = json [attr] + 'px ';
If (fnEnd) fnEnd ();
};
}, 30 );
}
Function setqq (obj, num ){
If (obj. length! = Num. length ){
Alert (the number of '\ nspan numbers does not match the number of QQ numbers. Please set up five QQ numbers! \ N [setting failed!] ');
Return;
} Else {
For (var I = 0; I <num. length; I ++ ){
Obj [I]. innerHTML = "<a target = '_ blank' href = 'HTTP: // wpa.qq.com/msgrd? V = 3 & uin = "+ num [I] +" & site = qq & menu = yes '> </a> ";
};
};
};
Function settop (id, id2, top ){
Var obj = document. getElementById (id );
Var box = document. getElementById (id2 );
Obj. style. top = box. style. top = top + 'px ';
};
Function dealy (id, time ){
Var obj = document. getElementById (id );
Var timer = setTimeout (function (){
Flexing (obj, {right:-100 });
}, Time * 1000 );
};
Function click_fn (id, id2 ){
Var obj = document. getElementById (id );
Var box = document. getElementById (id2 );
Obj. onclick = function (){
Running (obj, {right:-200}, function (){
Box. style. display = 'block ';
Running (box, {right: 10, opacity: 100 });
});
};
Box. onclick = function (){
Timer = setTimeout (function (){
Running (box, {right:-220, opacity: 0}, function (){
Box. style. display = 'none ';
Flexing (obj, {right:-100 });
});
},3000 );
};
};

Related Article

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.