Is the javaScript not part of the DOM?
Posted
by DKinzer
on Stack Overflow
See other posts from Stack Overflow
or by DKinzer
Published on 2010-04-25T03:15:03Z
Indexed on
2010/04/25
3:23 UTC
Read the original article
Hit count: 307
Why is it that scripts can still function even after the code used to create them is removed from the DOM?
I ran into a situation where I wanted to prevent a broken script from running (@see my post).
In my attempt to come up with a solution I wrote an extension with the following line (just to see what would happen).
//doc is passed here because this script is running as a firefox extension outside
//of the document context.
$('script', doc).remove();
I assumed that this would remove all the scripts from the DOM, which it did, and that therefore no scripts would run on the page, which is not the case.
I would love to know more about what's behind this behavior.
© Stack Overflow or respective owner