问题描述
在这种情况下,我必须从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.
谢谢!
推荐答案
是的,您可以删除< 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.
。执行脚本后,将保留对环境所做的修改。您只能通过卸载页面(或明确覆盖它们-如果可能的话)来撤消它们。
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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!