Start and Close chat events

To execute own javascript code when chat is started or closed, you can customize chat button integration code (with bold is marked our customization, the rest of the code is standard chat button integration code):

<script type="text/javascript">

(function(d, src, c) { var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');s.id='la_x2s6df8d';s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){var rs=this.readyState;if(rs&&(rs!='complete')&&(rs!='loaded')){return;}c(this);};t.parentElement.insertBefore(s,t.nextSibling);})(document,

'//localhost/LiveAgent/LiveAgent/server/scripts/trackjs_dev.php',

function(e){

var mybutton = LiveAgent.createButton('4c1d0e9f', e);

mybutton.oldOnClick = mybutton.onClick;
mybutton.oldOnCloseFunction_ = mybutton.onCloseFunction_;

mybutton.onClick = function() {
     mybutton.oldOnClick(); 
     //here is your code after chat is started, e.g. measure the size of chat window:
     console.log(mybutton.chat.element.offsetHeight);
     console.log(mybutton.chat.element.offsetWidth);
};

mybutton.onCloseFunction_ = function() {
     mybutton.oldOnCloseFunction_(); 
     //put here your javascript code executed after chat is closed
 }});

</script>

 

×