How do I make Chrome behave as IE5/IE6

459 views Asked by At

Strange request, I know.

We have a system written 15+ years ago that works only in IE with compatibility mode for IE5. Some of the things that don't work in newer browsers are related to the Javascript engine behaving in a very different way (there are many more issues, but this is the one I'm focusing on right now).

For example, you can do something like

document.frames

I can make this work in Chrome by extending the prototype of the HTMLDocument DOM object, something like:

Object.defineProperty(HTMLDocument.prototype, "frames", { get: function () { return document.getElementsByTagName("iframe"); } })

Obviously this won't work for every scenario but it will certainly speed up the process (and prevent having to modify half a million lines of JS). (Hopefully) this is not a final solution (or the most elegant one) but it can be an initial step to get it working fast before beginning a real refactoring.

I don't expect me being the first person with this approach to make an old app work on new browsers therefore I was wondering how do I solve this in a general way without writing a rule for every IE-specific property/method.

Thanks.

0

There are 0 answers