医疗行业网站经常会自定义咨询问页面,需要把客人在网页输入的内容传输到客服端,从而进行更有效的沟通,这里收集整理一些常用的方法。
HTML
1 2 3 4 5 6 7
| <textarea id="guest-txt" rows="5" placeholder="您可直接咨询在线医生,或者在输入框中描述您的问题。"></textarea>
<a href="javascript:void(0)" onclick="kstCon()">提交</a>
<script type="text/javascript" src="https://vipz2-hzbk2.kuaishang.cn/bs/ks.j?cI=xxxxxxx&fI=xxxx" charset="utf-8"></script>
|
JS
使用到的方法:KS.openChatWin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <script type="text/javascript">
function kstCon(){
var insertText=document.getElementById("guest-txt").value;
if(insertText||insertText!=""){
KS.openChatWin({
sText:'来自网页内嵌文本框的对话,客人输入的内容如下: '+insertText,
cv:'来自网页内嵌文本框的对话,客人输入的内容如下: '+insertText
}); }
else alert("请先填写您的问题哦!");document.getElementById("guest-txt").focus(); }
</script>
|
说明:网页中快商通代码换成自己公司的,里面用到的id,文本,函数名等等都可以自定义。