In this guide we’ll show you how you can launch and close your Chatway widget using a JavaScript function in a few super simple and quick clicks.
You can use this feature to launch or close your widget from anywhere on your website, for example through a button or an image.
How to open your Chatway widget
Let’s take the example from above. To launch the Chatway widget with a JavaScript function, add a button. It will serve as your custom button that visitors will click to open the Chatway widget. Then, add this code:
javascript:$chatway.openChatwayWidget();
Click here to see how it works:
You can also use the following code to launch the chat from a custom link. Here’s an example:
<a href="javascript:$chatway.openChatwayWidget();">Open Chat</a>
If you want to hide the Chatway icon in order to launch the widget through your custom button, please use the custom CSS code below:
.chatway--container .chatway--trigger-container {
display: none
}
How to close your Chatway widget
To close the Chatway widget with a JavaScript function, add a custom button, just like in the above example. It will serve as a button that visitors will click to close the Chatway widget. Then, add the JavaScript function.
javascript:$chatway.closeChatwayWidget();
Click here to see how it works:
That’s it! Easy as 1,2,3 ☺️
You can also check this guide on how to show and hide the Chatway widget here: