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>You can also use the following script to launch the chat from the Elementor button widget. Here’s an example:
<script>
// Select all buttons with that class
document.querySelectorAll('.openchatwindow').forEach(function(btn) {
btn.addEventListener('click', function(event) {
event.preventDefault();
$chatway.openChatwayWidget();
});
});
</script>You can use WPCode plugin and add the script in the Footer section.

Please note that the ID has to be exactly the same.
If you want to launch the Chatway widget from the Elementor button widget, please add your class in the CSS Classes field like in the example below:

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: