Netscape’s JavaScript 1.2 Incompatibilities

Netscape’s implementation of JavaScript 1.2 was released (as part of the Netscape 4.0 browser) while the ECMAScript v1 specification was still being finalized. The engineers at Netscape made some guesses about what would be in the specification, and based on those guesses, they made some changes to the way JavaScript behaved. Because these changes were not compatible with previous versions of JavaScript, the changes were implemented only when JavaScript 1.2 was explicitly requested. (In web browsers, this is done by setting the language attribute of the HTML <script> tag to “JavaScript1.2”.) This was an excellent way to introduce new behavior without breaking old scripts. Unfortunately, when work on ECMAScript v1 was completed, the new behavior that Netscape engineers had guessed at was not part of the standard. What this means is that Netscape’s implementation of JavaScript 1.2 has special-case behavior that is not compatible with JavaScript 1.1 and does not conform to the ECMAScript specification.

For compatibility with scripts that rely on the nonconforming behavior of JavaScript 1.2, all future implementations of JavaScript from Netscape have retained this special behavior when Version 1.2 is explicitly requested. Note, however, that if you request a version greater than 1.2 (with a language attribute of “JavaScript1.3”, for example) you will get ECMAScript-compliant behavior. Because this special behavior is present only in JavaScript ...

Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.