views:

20

answers:

2

I have a local file that I am displaying in an iframe. I cannot alter the file (or any files included- css, script, etc). I need to remove all of the tags from the file. This is easy enough, but I would like to remove them before the JavaScript inside them is executed. Simply doing:

window.onload = function(){
    iframeHEAD.removeChild(iframeSCRIPT);
}

will remove the script tag, but not before the script tag's code is executed.

A: 

You can't do that. Browsers interpret <script> content as soon as it's loaded.

Pointy
A: 

You can request the file with he XMLHttpRequest object, use a regular expression to remove the unwanted code from the string in the responseText, and than document.write the string into the iframe.

epascarello
Hey, that's a good idea. I was about to do it in PHP, but it might be better to do straight in JavaScript.
Azmisov