简体   繁体   English

Javascript 在 Wordpress 中消失了

[英]Javascript disappears in Wordpress

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 插件向我的网站添加实时聊天,并希望让客户通过单击文本链接来打开聊天。 Tawk.to gave me this link but when I paste that into my Wordpress editor it disappears as soon as I save the page. Tawk.to 给了我这个链接,但是当我将它粘贴到我的 Wordpress 编辑器中时,它会在我保存页面后立即消失。 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>这是链接: <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?有谁知道它为什么会消失以及如何修复?

WordPress's page / post editors won't let you put Javascript in pages or posts. WordPress 的页面/帖子编辑器不允许您将 Javascript 放入页面或帖子中。 Both editors (TinyMCE and Gutenberg) strip it out before saving your data, as you have seen.如您所见,两个编辑器(TinyMCE 和 Gutenberg)在保存数据之前都将其删除 This is to avoid cross-site-scripting attacks .这是为了避免跨站点脚本攻击 Because cybercreeps.因为网络蠕虫。

To use this tawk app in WordPress, follow their installation instructions .要在 WordPress 中使用这个 tawk 应用程序,请按照他们的安装说明进行操作 They provide a plugin .他们提供了一个插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM