欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript實(shí)現(xiàn)在線客服效果

 更新時(shí)間:2015年07月15日 11:08:50   投稿:hebedich  
這篇文章主要介紹了javascript實(shí)現(xiàn)在線客服效果的實(shí)例代碼,非常不錯(cuò),這里推薦給大家,有需要的小伙伴可以參考下。

在線客服系統(tǒng)在大量的網(wǎng)站都有應(yīng)用,特別是銷售類網(wǎng)站,可以有效的增加網(wǎng)站的可用性,便于客戶及時(shí)聯(lián)系商家,從而增加了交易成功的可能性,在線客服系統(tǒng)的實(shí)現(xiàn)方式有多種多樣,這里介紹一種網(wǎng)上常見(jiàn)并且非常美觀的客服系統(tǒng),以此達(dá)到舉一反三的目的,能夠比較輕松的實(shí)現(xiàn)其他外觀形式的客服系統(tǒng),代碼示例如下:

CSS

<style type="text/css">
body 
{
 margin:0px
}
.main_head 
{
 background:url(mytest/JS/img3-5_2.png) no-repeat;
}
*html .main_head 
{
 filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="mytest/JS/img3-5_2.png", sizingMethod='crop');
 background:none transparent scroll repeat 0% 0%;
}
* + html .main_head 
{
 background:url(mytest/JS/img3-5_2.png) no-repeat;
}
.info 
{
 padding-bottom:10px;
 padding-left:0px;
 padding-right:0px;
 background:url(mytest/JS/img3-5_3.png) repeat-y;
 padding-top:5px
}
* html .info 
{
 filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="mytest/JS/img3-5_3.png", sizingMethod='crop');
 background-repeat:repeat-y;
}
* + HTML .info 
{
 padding-bottom:10px;
 padding-left:0px;
 padding-right:0px;
 background:url(mytest/JS/img3-5_3.png) repeat-y;
 padding-top:5px;
}
.down_kefu 
{
 width:157px;
 background:url(mytest/JS/img3-5_4.png) no-repeat;
 height:8px
}
* html .down_kefu 
{
 filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="mytest/JS/img3-5_4.png", sizingMethod='crop');
 width:157px;
 background-repeat:repeat-y;
 height:8px
}
* + HTML .down_kefu 
{
 width:157px;
 background:url(mytest/JS/img3-5_4.png) no-repeat;
 height:8px
}
.Obtn 
{
 margin-top:104px;
 width:32px;
 background:url(mytest/JS/img3-5_1.png) no-repeat;
 float:left;
 height:139px;
 margin-left:-5px
}
* HTML .Obtn 
{
 filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="mytest/JS/img3-5_1.png", sizingMethod='crop');
 width:32px;
 background:none transparent scroll repeat 0% 0%;
 float:left;
 height:139px
}
* + html .Obtn 
{
 margin-top:104px;
 width:32px;
 background:url(mytest/JS/img3-5_1.png) no-repeat;
 float:left;
 height:139px;
 margin-left:-5px;
}
.qqtable span
{
 padding-bottom:5px;
 line-height:20px;
 padding-left:0px;
 width:100px;
 padding-right:0px;
 color:#ff6600;
 font-size:13px;
 font-weight:bold;
 padding-top: 5px
}
.qqtable a 
{
 text-decoration:none;
}
.qqtable a:hover 
{
 text-decoration: none
}
.qun 
{
 border-bottom:#ffd2bf 1px solid;
 border-left:#ffd2bf 1px solid;
 padding-bottom:5px;
 line-height:20px;
 background-color:#ffffff;
 padding-left:0px;
 width:100px;
 padding-right:0px;
 font-size:12px;
 border-top:#ffd2bf 1px solid;
 border-right:#ffd2bf 1px solid;
 padding-top:5px
}
.qun span 
{
 color:#ff6600;
 font-size:13px;
 font-weight:bold;
}
</style>

html

<div id="softwhy">
<table style="float:left" border="0" cellspacing="0" cellpadding="0" width="157">
<tbody>
 <tr>
  <td class="main_head" height="39" valign="top"> </td>
 </tr>
 <tr>
  <td class="info" valign="top">
  <table class="qqtable" border="0" cellspacing="0" cellpadding="0" width="120" align="center">
   <tbody>
   <tr>
    <td align=middle><a href="#" target="_blank"><img border=0 src="mytest/JS/kefu_head.gif"></a></td>
   </tr>
   <tr>
    <td height=5></td>
   </tr>
   <tr>
    <td height=30 align=middle><span>qq:88888888</span></td>
   </tr>
   <tr>
    <td height=30 align=middle><span>qq:88888888</span></td>
   </tr>
   <tr>
    <td height=5></td>
   </tr>
   <tr>
    <td height=35 valign=top align=middle><a href="#" target="_blank"><img border=0 src="mytest/JS/img3-5-btn1.gif" width=90 height=25></a></td>
   </tr>
   <tr>
    <td height=38 valign=top align=middle><a href="#" target="_blank"><img border=0 src="mytest/JS/img3-5-btn2.gif" width=90 height=25></a></td>
   </tr>
   <tr>
    <td align=middle><div class=qun><font color=#9b9b9b>會(huì)員交流群</font><br><span>123456</span></div></td>
   </tr>
   <tr>
    <td align=middle><div class=qun><font color=#9b9b9b>商家交流群</font><br><span>654321</span></div></td>
   </tr>
   <tr>
    <td align=middle> </td>
   </tr>
   </tbody>
  </table>
  </td>
 </tr>
 <tr>
  <td class="down_kefu" valign="top"></td>
 </tr>
</tbody>
</table>
<div class="Obtn"></div>
</div>
<div style="height:1000px;"></div>

JS

<script type="text/javascript">
kefu=function(id,_top,_left){
var me=document.getElementById(id);
var d1=document.body;
var d2=document.documentElement;
d1.style.height=d2.style.height='100%';
me.style.top=_top+'px';
me.style.left=_left+"px";
me.style.position='absolute';
function a()
{
  me.style.top=parseInt(me.style.top)+(Math.max(d1.scrollTop,d2.scrollTop)+_top-parseInt(me.style.top))*0.1+'px';
}
setInterval(a,10+parseInt(Math.random()*20));
}
 
window.onload=function(){
  kefu('softwhy',100,-152)
}
</script> 
 
<script type="text/javascript"> 
 var InterTime=1;
 var maxWidth=-1;
 var minWidth=-152;
 var numInter=10;
 var BigInter;
 var SmallInter;
 var o=document.getElementById("softwhy");
 var i=parseInt(o.style.left);
 function Big()
 {
  if(parseInt(o.style.left)<maxWidth)
  {
   i=parseInt(o.style.left);
   i+= numInter;    
   o.style.left=i+"px";    
   if(i==maxWidth)
    clearInterval(BigInter);
   }
 }
  
 function toBig()
 {
  clearInterval(SmallInter);
  BigInter=setInterval(Big,InterTime);
 }
 function Small()
 {
  if(parseInt(o.style.left)>minWidth)
  {
   i=parseInt(o.style.left);
   i=i-numInter;
   o.style.left=i+"px";
   if(i==minWidth)
    clearInterval(SmallInter);
   }
 }
 function toSmall()
 {
  clearInterval(BigInter);
  SmallInter=setInterval(Small,InterTime);                
 }            
</script>

以上代碼實(shí)現(xiàn)了我們想要的在網(wǎng)頁(yè)一側(cè)漂浮的客服系統(tǒng)。下面就簡(jiǎn)單介紹一下如何實(shí)現(xiàn)次效果:

一.實(shí)現(xiàn)原理:

將整個(gè)客服系統(tǒng)所在的softwhy對(duì)象設(shè)置為絕對(duì)定位,然后在默認(rèn)狀態(tài)下,將它的left屬性值設(shè)置為一個(gè)恰當(dāng)?shù)呢?fù)值,這樣它主體部分就會(huì)被隱藏,只顯示提示部分:

默認(rèn)狀態(tài)下被隱藏的主體部分。

默認(rèn)狀態(tài)下顯示的提示部分。

當(dāng)鼠標(biāo)放在放在提示部分(也就是放在softwhy對(duì)象)時(shí)候,通過(guò)調(diào)用相應(yīng)的函數(shù),使用setInterval()不斷的加大left屬性值來(lái)實(shí)現(xiàn)客服主體部分逐漸顯示的效果。當(dāng)鼠標(biāo)離開(kāi)softwhy對(duì)象的時(shí)候,再通過(guò)調(diào)用相應(yīng)的函數(shù),使用setInterval()不斷的減少left屬性值來(lái)實(shí)現(xiàn)客服主體部分的逐漸隱藏。

softwhy對(duì)象top屬性值在這里可能是個(gè)難點(diǎn),它實(shí)現(xiàn)了當(dāng)拖動(dòng)滾動(dòng)條的時(shí)候,客服系統(tǒng)具有比較任性的“彈性”的感覺(jué),并且最終能夠固定在距離窗口頂端100px的垂直位置上,此效果是結(jié)合a函數(shù)和setInterval(a,10+parseInt(Math.random()*20))實(shí)現(xiàn)的,這里簡(jiǎn)單介紹一下a函數(shù)的原理,主要是個(gè)數(shù)學(xué)問(wèn)題:

我們想要實(shí)現(xiàn)的效果就是無(wú)論怎么拖動(dòng)滾動(dòng)條,客服系統(tǒng)最終在垂直位置上距離窗口上邊緣100px,也就是說(shuō)只要將top屬性值設(shè)置為d1.scrollTop或者d2.scrollTop與100px之和就可以了。下面簡(jiǎn)單對(duì)a函數(shù)進(jìn)行一下分析:

Math.max(d1.scrollTop,d2.scrollTop)+_top-parseInt(me.style.top)中,Math.max(d1.scrollTop,d2.scrollTop)+_top就是me.style.top的最終值,在通過(guò)使用setInterval()函數(shù)循環(huán)執(zhí)行a函數(shù),也就是不斷的執(zhí)行parseInt(me.style.top)+(Math.max(d1.scrollTop,d2.scrollTop)+_top-parseInt(me.style.top))*0.1+'px',當(dāng)me.style.top=Math.max(d1.scrollTop,d2.scrollTop)+_top的時(shí)候,客服系統(tǒng)也就是固定在指定的位置了。

以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。

相關(guān)文章

最新評(píng)論