且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

除去附加的javascript脚本

更新时间:2023-12-05 17:54:10

我做了一些更多的测试,之前你会得到一个正确回答你的问题(希望有一个),你可以试试这个:

I did some more tests, and before you'll get a correct answer to your question (hope there is a one) you can try this:

<button onclick="foo()">ShowHTML</button>
<script>
(function foo(){
    var b=function moo(){
        var c=document.getElementsByTagName('script');
        alert(document.body.innerHTML);
        c[0].parentElement.removeChild(c[0]);
        alert(document.body.innerHTML);
    }
    var a=setTimeout(b,1000);
    b=null;
})();
foo=null;
</script>

这只是测试code,但它包含了一个想法,你怎么可能可以解决这个问题。它消除了&LT; sript方式&gt; 从DOM,最后一行破坏脚本的所有功能。

This is just a test code, but it contains an idea, how you possible could solve the problem. It removes <sript> from the DOM, and the last line destroys all functionality of the script.

(将code也有一个小细节,这表明,该的setTimeout 将尽的eval(),不管它是如何argumented ...?)

(The code also has a little detail, which shows, that setTimeout will do eval(), no matter how it is argumented...?)