2

I'm using the Tawk.to plugin to add a live chat to my website, and want to let customers open the chat by clicking a text link. Tawk.to gave me this link but when I paste that into my Wordpress editor it disappears as soon as I save the page. I paste it in the text screen as well as by inserting it as a hyperlink on the visual editor screen.

This is the link: <a href="javascript:void(Tawk_API.toggle())"> Click to Chat </a>

This is what I completely have on the website:

<div class="text">
<div class="phone"><strong>Vragen?</strong> <i class="fa fa-comments"></i><a href="javascript:void(Tawk_API.toggle())"> Click to Chat </a></div>

Does anyone know why it disappears and how it can be fixed?

O. Jones
  • 103,626
  • 17
  • 118
  • 172

1 Answers1

0

WordPress's page / post editors won't let you put Javascript in pages or posts. Both editors (TinyMCE and Gutenberg) strip it out before saving your data, as you have seen. This is to avoid cross-site-scripting attacks. Because cybercreeps.

To use this tawk app in WordPress, follow their installation instructions. They provide a plugin.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • Thanks for your answer. I already installed and using the plugin. In their documentation they say you can open the chatbox via the code I mentioned above. But as you say it's stripped out by Wordpress. Is there a workaround maybe? – MediaCreandum Jul 07 '22 at 11:27
  • I suspect the documentation telling you to use that HTML/Javascript combination does not apply to WordPress. Use their widget. Ask them to add a shortcode to the next version of the plugin. – O. Jones Jul 07 '22 at 11:34