JavaScript version

How can a JavaScript script know what version of the JavaScript language the browser supports?

Here’s a cruddy kludge that has been recommended as a way to determine this. It uses the language attribute of the HTML script tag. However, many browsers just ignore that attribute.

So far it doesn’t look good:

Browser Platform JavaScript Version
MSIE 6 Windows ignores
MSIE 5 Mac and Windows ignores
MSIE 4.01 Mac 1.2
Firefox 3 Linux ignores
NS 6 Mac, Linux, and Windows 1.5
NS 4.x Mac, Linux, and Windows ignores
NS 3.04 Mac 1.1
NS 2.0 Mac ignores
Opera 9 Linux ignores
Opera 5, 6 Mac, Linux, and Windows 1.4
iCab 2.5.2 Mac ignores
KonquerorLinux ignores
HotJava 3.0Java 1.4
Ice Browser 5.0.6Java 1.4

JScript supports a nice feature called “conditional compilation” and has a means of retrieving the version of JScript that's running.