문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top