I think your problem is not that there are different javascript engines (although there are). The problem that you are describing (that you need different code to get the same functionality) is probably because of various browsers understanding of HTML and particularly their implementation of the DOM. The work around HTML5 hopefully address a number of the areas of concern (although not all). This is taken directly from the HTML5 draft spec
1.5 Design notes
This section is non-normative.
It must be admitted that many aspects of HTML appear at first glance to be nonsensical and inconsistent.
HTML, its supporting DOM APIs, as well as many of its supporting technologies, have been developed over a period of several decades by a wide array of people with different priorities who, in many cases, did not know of each other's existence.
Features have thus arisen from many sources, and have not always been designed in especially consistent ways. Furthermore, because of the unique characteristics of the Web, implementation bugs have often become de-facto, and now de-jure, standards, as content is often unintentionally written in ways that rely on them before they can be fixed.
I think that expresses the problem quite nicely.