This article mainly introduces the sample code of online customer service of floating scroll qq on the right side of the webpage. For more information, see the code of online customer service of floating scroll QQ on the right side of the webpage.
The 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 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 Obj [I]. innerHTML = "";
};
};
};
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 );
};
};