简体   繁体   中英

rewriting Javascript before it's loaded by the browser

I need to arbitrarily rewrite Javascript code, client-side, before it's loaded by the browser. I would like to handle script tags as well as referenced .js files. Dynamically generated script tags are not a goal. My client is running a proprietary system, so this only needs to work with IE for now (IE6+). I've read up on MIME-filtering, but I don't think that would take care of static script tags, just .js files.

What is the use case for this? It sounds like an approach to be avoided if at all possible. You will lose any ability to cache javascript for one thing.

Can you give an example of the kinds of rewriting you want to do?

Ouch, nasty. Would it be possible to configure users' browser with a custom proxy which can parse and rewrite the javascript? This could be pushed out with group policy (if the browsers are not already configured with proxies)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM