我可以使用另一个Javascript从DOM中删除Javascript吗? [英] Can I remove a javascript from the DOM with another Javascript?

查看:70
本文介绍了我可以使用另一个Javascript从DOM中删除Javascript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,我必须从DOM中删除脚本标签,而只能为此使用其他脚本。
我知道这不是一种很好的工作方式,但这是目前唯一的选择。

I have this situation where I have to delete a script tag from the DOM with only the possibility of using another script for this. I know this isn't a good way of working, but it's the only option at this time.

因此,我的问题是这是否可能。我认为删除该脚本后,您仍然可以使用其中的功能。

Therefor my question is if this is possible. I think that when I delete this script you will still be able to use the functions inside.

谢谢!

推荐答案


是可以为此使用其他脚本从DOM中删除脚本标签。

Is it possible to delete a script tag from the DOM by using another script for this.

是的,您可以删除< script> 节点,因为您也可以修改任何其他节点。您甚至可以编写一个删除其自身元素的脚本。

Yes, you can remove <script> nodes from the DOM as you can modify any other nodes as well. You even can write a script that removes it's own element.


我认为,删除该脚本后,您仍然可以使用

I think that when I delete this script you will still be able to use the functions inside.

这是正确的。执行脚本后,将保留对环境所做的修改。您只能通过卸载页面(或明确覆盖它们-如果可能的话)来撤消它们。

That is correct. When the script has already been executed, the modifications it made to the environment will remain. You can't undo them other than by unloading the page (or explicitly overwriting them - if possible).

这篇关于我可以使用另一个Javascript从DOM中删除Javascript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆