Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove script from site before being executed

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

like image 787
user2028856 Avatar asked Jun 19 '26 01:06

user2028856


1 Answers

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.

like image 134
vol7ron Avatar answered Jun 21 '26 15:06

vol7ron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!