bi******@yahoo. co.uk wrote:
Is ECMAscript a new independant cross platform
specification that can do loads of nice things that JavaScript can do?
ECMAScript is nothing new, the latest edition of that standard is
edition 3 which was published in 1999.
It is a standardization of the core language (e.g. the types like
number, string, boolean, object, the operators like +, -, *, typeof
delete, the expressions, the native objects like Object, Function, Date,
Array, String, Number, Boolean, RegExp, Error, the statements like
if/else, while) a scripting engine like the (former Netscape now
Mozilla) Spidermonkey engine or the MS JScript engine implements.
At the time of publication the 3rd edition contained some features (like
try/catch/finally exception handling) not yet or not yet completely
implemented but for some years now the latest versions of the
implementations (JavaScript 1.5, JScript 5.5 and 5.6, Opera's engine
since at least Opera 7) are trying to implement that edition completely.
As for scripting in the browser that standard of course helps achieving
compatible behavior for the stuff mentioned above that it covers, but
that is as you can see not anything browser related. And for quite some
time on the web you had (or depending on your views you still have) to
deal with various browsers (for instance like Netscape 4) which do not
implement the complete language like try/catch and throw syntax errors
on such statements so you could (or still can) not simply rely on things
in the standard and use them.
In regards to web scripting (of HTML documents and XML documents) what
is more important than the ECMAScript specification is the W3C DOM
specification <http://www.w3.org/DOM/DOMTR#dom2>, it specifies its
objects respectively interfaces and properties and methods in an IDL, in
a Java binding, and in an ECMAScript binding.
But that specification has three levels and the three levels have
different modules finished between 1998 and 2004, if you look at the age
of IE 6, the currently latest IE version on Windows, it becomes clear
that you cannot simply rely on the W3C DOM specification to write cross
browser compatible scripts.
IE is certainly the greatest problem as its DOM implementation has grown
from the not W3C compatible IE 4 DOM and then it seems the W3C DOM has
been implemented on top of that where it was easy or seen more useful.
So with IE you can often experience the surprise that a core DOM method
like appendChild works on some elements or with some argument but not
with others. In such cases there are often ways using the IE DOM to
achieve what you want but then you have to fork and write one branch of
code using the W3C DOM stuff and another using the IE DOM stuff.
On the other hand of the other current browsers like Mozilla, Opera,
Safari, Konqueror only Mozilla for some time had the high goal to
implement the W3C DOM first and only while Opera for instance as far as
I see it always tried to be compatible to both the W3C DOM and the IE DOM.
By now you will find a wide spread use of a mixture of the W3C DOM (for
instance createElement) and the IE DOM (for instance innerHTML).
So there is no short and simple answer, it certainly helps to read the
W3C DOM standards and learn to understand what that standard then means
in an ECMAScript implementation but you will still need to learn the
particular implementations in different browsers.
--
Martin Honnen
http://JavaScript.FAQTs.com/