I have a site I'm loading via iframe and it's on the same server. I need to remove a certain script tag before the page inside the iframe is loaded. In order words, intercept and remove the script before it's executed.
I tried
var x = doc.getElementsByTagName('script');
doc.getElementsByTagName('head').removeChild(x);
But this doesn't seem to be able to catch the script before it executes. What other methods or options exist to achieve this objective?
Thanks
I don't think you can stop it from loading in the setup you've described.
However, you can point your iframe to your own server-side script (eg perl, php) which retrieves the URL and strips the script, then return everything else.
<script type="text/plain">
alert('foo')
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.