views:

53

answers:

2

I need to arbitrarily rewrite Javscript 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.

Can anyone point me in the right direction. This is an unfamiliar area for me...

A: 

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)

x0n
+1  A: 

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?

RedFilter
I'm curious too. If the JS needs to be dynamically generated, why not by the server?
Matt