Example of qq online customer service plug-in implemented by jquery on the right of the webpage

Source: Internet
Author: User

A very practical QQ online customer service code, click the QQ icon, you can directly talk to customer service. The specific implementation code is as follows:
Html page: Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> implement qq customer service using jquery </title>
<Link rel = "stylesheet" type = "text/css" href = "css/base.css"/>
<Script type = "text/javascript" src = "js/jquery-1.8.3.min.js"> </script>
<Script type = "text/javascript" src = "js/qqservice. js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("Body"). Sonline ({
Position: "right", // left or right
Top: 200, // The distance from the Top. The default value is PX.
Effect: true, // scroll or fixed in two ways. boolean value: true or false
DefaultsOpen: true, // expand by default: true, shrink by default: false
Qqlist: "<SPAN> 435027 | customer service | 435027 | customer service, | customer service 05 </SPAN>" // separate multiple QQ sets by commas, separate QQ and customer service names with '|'
});
})
</Script>
</Head>
<Body>
<Div style = "height: 2500px"> </div>
<Div style = "text-align: center; clear: both"> </div>
</Body>
</Html>

Css style:Copy codeThe Code is as follows:/* default blue */
. SonlineBox {width: 162px; font-size: 12px; overflow: hidden; z-index: 9999 ;}
. SonlineBox. openTrigger {width: 30px; height: 110px; position: absolute; top: 0px; z-index: 1; cursor: pointer; background: # 0176ba url (.. /images/openTrigger.jpg) no-repeat ;}
. SonlineBox. titleBox {width: 158px; height: 35px; line-height: 35px; background: # 038bdc url (.. /images/SonlineTitleBg.gif) repeat-x; border-bottom: 2px solid # 0176ba ;}
. SonlineBox. titleBox span {margin-left: 10px; color: # fff; font-size: 14px; font-family: ' ', 'simhei ';}
. SonlineBox. contentBox {width: 158px; height: auto; border: 2px solid # 0176ba; background: # fff; position: absolute; z-index: 2 ;}
. SonlineBox. contentBox. closeTrigger {width: 25px; height: 25px; display: block; cursor: pointer; position: absolute; top: 5px; right: 5px;-webkit-transition: all 0.8 s outgoing-out ;}
. SonlineBox. contentBox. closeTrigger: hover {-webkit-transform: scale (1) rotate (360deg );}
. SonlineBox. contentBox. listBox {overflow: hidden; margin-bottom: 10px ;}
. SonlineBox. contentBox. listBox. QQList {display: block; width: 86%; height: 22px; margin: 10px auto 0px auto ;}
. SonlineBox. contentBox. listBox. QQList span {float: left; line-height: 22px ;}
. SonlineBox. contentBox. listBox. QQList a {float: left ;}

Jquery script code:Copy codeThe Code is as follows :/*
This plug-in is based on Jquery
Developer yaohucaizi
Blog: http://blog.csdn.net/yaohucaizi/
*/
(Function ($ ){
$. Fn. Sonline = function (options ){
Var opts = $. extend ({}, $. fn. Sonline. defualts, options );
$. Fn. setList (opts); // call list settings
If (opts. DefaultsOpen = false ){
$. Fn. Sonline. close (opts. Position, 0 );
}
// Expand
$ ("# SonlineBox>. openTrigger"). live ("click", function () {$. fn. Sonline. open (opts. Position );});
// Close
$ ("# SonlineBox>. contentBox>. closeTrigger "). live ("click", function () {$. fn. sonline. close (opts. position, "fast ");});

// Ie6 compatible or scrolling display
If ($. browser. msie & ($. browser. version = "6.0 ")&&! $. Support. style | opts. Effect = true) {$. fn. Sonline. scrollType ();}
Else if (opts. Effect = false) {$ ("# SonlineBox" ).css ({position: "fixed "});}
}
// Plugin defaults
$. Fn. Sonline. defualts = {
Position: "left", // left or right
Top: 200, // The distance from the Top. The default value is PX.
Effect: true, // scroll or fixed in two ways. boolean value: true or
DefaultsOpen: true, // expand by default: true, shrink by default: false
Qqlist: "" // use commas (,) to separate multiple QQ accounts. Use commas (,) to separate QQ accounts from customer service accounts (| ).
}

// Expand
$. Fn. Sonline. open = function (positionType ){
Var widthValue = $ ("# SonlineBox>. contentBox"). width ();
If (positionType = "left") {$ ("# SonlineBox>. contentBox"). animate ({left: 0}, "fast ");}
Else if (positionType = "right") {$ ("# SonlineBox>. contentBox"). animate ({right: 0}, "fast ");}
$ ("# SonlineBox" ).css ({width: widthValue + 4 });
$ ("# SonlineBox>. openTrigger"). hide ();
}
// Close
$. Fn. Sonline. close = function (positionType, speed ){
$ ("# SonlineBox>. openTrigger"). show ();
Var widthValue = $ ("# SonlineBox>. openTrigger"). width ();
Var allWidth = (-($ ("# SonlineBox>. contentBox"). width ()-6 );
If (positionType = "left") {$ ("# SonlineBox>. contentBox"). animate ({left: allWidth}, speed );}
Else if (positionType = "right") {$ ("# SonlineBox>. contentBox"). animate ({right: allWidth}, speed );}
$ ("# SonlineBox"). animate ({width: widthValue}, speed );

}
// Sub-plug-in: Set LIST Parameters
$. Fn. setList = function (opts ){
$ ("Body "). append ("<div class = 'linebox' id = 'linebox' style = 'top:-600px; '> <div class = 'opentrigger' style = 'display: none 'title = 'expanded'> </div> <div class = 'contentbox'> <div class = 'closetrigger'> </div> <div class = 'titlebox'> <span> Customer Service Center </span> </div> <div class = 'listbox'> </div> </div> ");
If (opts. qqlist = "") {$ ("# SonlineBox>. contentBox>. listBox "). append ("<p style = 'padding: 15px '> no online customer service is available. </P> ")}
Else {var qqListHtml = $. fn. Sonline. splitStr (opts); $ ("# SonlineBox>. contentBox>. listBox"). append (qqListHtml );}
If (opts. Position = "left") {$ ("# SonlineBox" ..css ({left: 0 });}
Else if (opts. Position = "right") {$ ("# SonlineBox" ).css ({right: 0 })}
$ ("# SonlineBox" ).css ({top: opts. Top });
Var allHeights = 0;
If ($ ("# SonlineBox>. contentBox"). height () <$ ("# SonlineBox>. openTrigger"). height ()){
AllHeights = $ ("# SonlineBox>. openTrigger"). height () + 4;
} Else {allHeights =$ ("# SonlineBox>. contentBox"). height () + 4 ;}
$ ("# SonlineBox"). height (allHeights );
If (opts. Position = "left") {$ ("# SonlineBox>. openTrigger" ).css ({left: 0 });}
Else if (opts. Position = "right") {$ ("# SonlineBox>. openTrigger" ).css ({right: 0 });}
}

// Sliding effect
$. Fn. Sonline. scrollType = function (){
$ ("# SonlineBox" ).css ({position: "absolute "});
Var topNum = parseInt ($ ("# SonlineBox" ).css ("top") + "");
$ (Window). scroll (function (){
Var scrollTopNum = $ (window). scrollTop (); // obtain the height of the page to be rolled
$ ("# SonlineBox"). stop (true, true). delay (0). animate ({top: scrollTopNum + topNum}, "slow ");
});
}

// Separate QQ
$. Fn. Sonline. splitStr = function (opts ){
Var strs = new Array (); // defines an Array
Var QqlistText = opts. Qqlist;
Strs = QqlistText. split (","); // delimiter
Var QqHtml = ""
For (var I = 0; I <strs. length; I ++ ){
Var subStrs = new Array (); // defines an Array
Var subQqlist = strs [I];
SubStrs = subQqlist. split ("|"); // delimiter
QqHtml = QqHtml + "<div class = 'qqlist'> <span>" + subStrs [1] + ": </span> <a target = '_ blank' href = 'HTTP: // wpa.qq.com/msgrd? V = 3 & uin = "+ subStrs [0] +" & site = qq & menu = yes '> </a> </div>"
}
Return QqHtml;
}
}) (JQuery );

As follows:

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.