在线客服系统

原创 2018-12-15 21:37:46 202
摘要:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>在线客服系统</title> <style type="text/css"> div:nth-child(1){ width:500px; heigh

1544880994982582.jpg

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>在线客服系统</title>

<style type="text/css">

div:nth-child(1){

width:500px;

height: 600px;

background-color:pink;

margin:30px auto;

color:#333;

box-shadow: 2px 2px 2px #808080

}

h2{

text-align: center;

margin-bottom:-20px

}

div:nth-child(2){

width:420px;

height: 450px;

border:3px double orange;

background-color: #efefef;

margin: 30px auto 10px;

}

UL{

list-style-type:none;

line-height:2em;

overflow:hidden;

padding:15px;

}

table{

width: :90%;

height:80px;

margin: auto;

}

textarea{

border:none;

resize:none;

background-color: #efefef;

}

button{

width: 50px;

height: 40px;

border:none;

background-color:red;

}

button:hover{

cursor:pointer;

background-color: orange;

}

</style>

</head>

<body>

<div>

  <h2>在线客服</h2>

  <div>

<ul>

<li></li>

</ul>

  </div>

  <table>

<tr>

<td align="right"><textarea name="text" cols="50"  rows="4"></textarea></td>

<td align="left"><button type="button">发送</button></td>

</tr>

  </table>

 </div>

 <script>

 let btn=document.getElementsByTagName('button')[0];

 let text=document.getElementsByName('text')[0];

 let list= document.getElementsByTagName('ul')[0];

 let sum=0;


  btn.onclick=function(){

  if (text.value.length===0){

  alert('您还没有说话!');

  return false;

  }

  let userComment = text.value;

  text.value='';

  let li=document.createElement('li');

 

  let userPic = '<img src= "aa.jpg" width="30" style="border-radius:50%">';

  li.innerHTML = userPic + '' + userComment;

  list.appendChild(li);

  sum += 1;


  setTimeout(function(){

  let info = ['1有什么希要帮忙吗?',

     '2有什么希要帮忙吗?',

     '3有什么希要帮忙吗?',

     '4有什么希要帮忙吗?',

     '5有什么希要帮忙吗?'

  ];

  let temp = info[Math.floor(Math.random()*4)];

  let replay = document.createElement('li');

  let kfPic = '<img src= "bb.jpg" width="30" style="border-radius:50%">';

  replay.innerHTML = kfPic + ' ' + '<span style="color:red">'+ temp +'</span>';

  list.appendChild(replay);

  sum += 1;

  },1000);


  if(sum>8){

  list.innerHTML='';

  sum=0;

  }

  }

 </script>

</body>

</html> 


发布手记

热门词条