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>
  // 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:

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: 

Plans That Fit Every Stage of Your Growth

Start free and upgrade as your needs expand. Whether you’re working solo, leading a team, or scaling big, we’ve got a plan built for you.

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
5 stars reviews
1,000+ Five-Star Reviews on iOS & android app stores

Company

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

Resources

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

© 2026 Chatway. All rights reserved.

GDPR icon
Accessibility Adjustments

Powered byOneTap

How long do you want to hide the toolbar?
Hide Toolbar Duration
Select your accessibility profile
Vision Impaired Mode
Enhances website's visuals
Seizure Safe Profile
Clear flashes & reduces color
ADHD Friendly Mode
Focused browsing, distraction-free
Blindness Mode
Reduces distractions, improves focus
Epilepsy Safe Mode
Dims colors and stops blinking
Content Modules
Font Size

Default

Line Height

Default

Color Modules
Orientation Modules