jquery实现漂浮在网页右侧的qq在线客服插件示例

2020-05-24 21:29:34易采站长站整理

if(opts.Qqlist==””){$(“#SonlineBox > .contentBox > .listBox”).append(“<p style=’padding:15px’>暂无在线客服。</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});}
}
//滑动式效果
$.fn.Sonline.scrollType = function(){
$(“#SonlineBox”).css({position:”absolute”});
var topNum = parseInt($(“#SonlineBox”).css(“top”)+””);
$(window).scroll(function(){
var scrollTopNum = $(window).scrollTop();//获取网页被卷去的高
$(“#SonlineBox”).stop(true,true).delay(0).animate({top:scrollTopNum+topNum},”slow”);
});
}
//分割QQ
$.fn.Sonline.splitStr = function(opts){
var strs= new Array(); //定义一数组
var QqlistText = opts.Qqlist;
strs=QqlistText.split(“,”); //字符分割
var QqHtml=””
for (var i=0;i<strs.length;i++){
var subStrs= new Array(); //定义一数组
var subQqlist = strs[i];
subStrs = subQqlist.split(“|”); //字符分割
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’><img border=’0′ src=’http://wpa.qq.com/pa?p=2:”+subStrs[0]+”:41 &r=0.22914223582483828′ alt=’点击这里’></a></div>”
}
return QqHtml;
}
})(jQuery);

效果图如下: