简体   繁体   English

单击按钮时如何卸载脚本?

[英]How to unload a script when a button is clicked?

So on my website, I integrated a plugin called manychat. 因此,在我的网站上,我集成了一个名为manychat的插件。 This is implemented by a <script> ; 这是通过<script>

When I click on the Drawer Cart this manychat symbol overlays over the checkout button, which doesn't look nice. 当我单击“抽屉购物车”时,此多聊天符号覆盖在结帐按钮上,看起来不太好。

So when I click the "cart" button it should unload this script. 因此,当我单击“购物车”按钮时,它应该卸载此脚本。 With the next action, it should then be loaded again. 在执行下一步操作后,应再次加载它。

Is this possible? 这可能吗?

I am using Shopify 我正在使用Shopify

<script src="//widget.manychat.com/1541935499435047.js" async="async"></script>

You can't unload a script once loaded. 加载脚本后,您将无法卸载脚本。 You can, however, dig deep in to the script and cancel out the global variables it create - and undo what it does to your DOM such as any event listeners it might have registered. 但是,您可以深入研究该脚本并取消其创建的全局变量-并撤消它对DOM的作用,例如它可能已注册的任何事件侦听器。

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

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