Chatway Chatway
  • Home
  • Product
  • Pricing
  • Built For
  • Resources
    • Help Center
    • Blog
    • Integrations
    • Social Media Buttons
    • Glossary
  • What’s New
  • Sign In →
Sign In Sign Up for Free Free Sign Up

How to open or close your Chatway widget using JavaScript

  • Help Center >
  • For developers >
  • How to open or close your Chatway widget using JavaScript

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:

Open the widget

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>
document.getElementById('YourElementorButtonID').addEventListener('click', function(event) {
event.preventDefault(); // Prevents default button behavior
$chatway.openChatwayWidget(); // Opens the Chatway widget
});
</script>

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 ID in the widget CSS ID 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:

Close the widget

That’s it! Easy as 1,2,3 ☺️

You can also check this guide on how to show and hide the Chatway widget here: 

A Plan That Grows With You Free Forever or Go Pro

Our free plan is built for most businesses. Pro is there when you need extra power and flexibility.

Sign Up for Free

No Credit Card Required

Chatway essential features
Capterra Capterra 2 Grid Leader Grid Leader High performancer 1 High performancer 2 High performancer 3 High performancer 4 High performancer 5 GetApp Customer Support
chatway footer logo

Improve live chat communication and unlock customer satisfaction with Chatway

app store logo play store logo

Company

  • About Us
  • Privacy Policy
  • GDPR
  • Terms of Service
  • Pricing

Resources

  • Contact Us
  • Integrations
  • Built For
  • Help Center
  • Comparison Page

© 2025 Chatway. All rights reserved.