When it comes to DHTML Mozilla might be less powerful than IE4 but when it comes to JavaScript it just kicks ass. The first time a saw a setter being used with a prototype of the built-in HTMLElement constructor I was just blown away. One of my first thought at that time was that this was exactly what I needed to start emulating the IE DHTML Object Model for Mozilla.

The goal of this article is to emulate a lot of IE behaviors to work in Mozilla, both to make old IE specific scripts work in Mozilla but also to make it easier to create new scripts that work in both IE5 and Mozilla. The article is actually going to be a series of smaller articles, each one concentrating on a small part of the emulation.


As a proof of concept I've created a rough emulation that works (almost) good enough to get the generic move script to work.

Generic move using the emulator

There where two things that had to be fixed in this script but I hope to be able to emulate those in the future because they are way too common to ignore. The first one was setting a css value without a unit (ie "px"). The second one was referencing an element with document.all.

The IE Emu Series

Next I will cover the core technologies allowing the emulation. The absolutely most import parts are the JavaScript 1.5 setters and getters as well as the ability to get a native js object constructor for any object.

The power of JS
Event Listeners
Classic Event Handlers
Event Object
InnerHTML Model
Element Model
Document All Model
Current Style Model

Author: Erik Arvidsson