script language attribute / JavaScript version

There used to be a very nice attribute to the script tag that defined what version of JavaScript is present between the script tags. You’d say language=”JavaScript1.3″ and older browsers that only supported JavaScript 1.2 wouldn’t run the code. Unfortunately this is not the case anymore – the attribute has been deprecated and browsers don’t really support it anymore. IE says that JS 1.3 is the latest version it supports, Firefox and Safari support 1.7. Opera supports 1.5 and surprisingly all the 2.x version (huh?) and the browser in Blackberry (the reason for testing this) supports everything.

I know – search for what you need, but in this case I don’t really want to check for all the objects and methods that I need…

Check your own browsers JavaScript support.

3 Responses to “script language attribute / JavaScript version”

  1. steve says:

    yeah, this was a nice idea at the time, but since MSIE’s “version” of IE differed greatly from the *real* version of JavaScript, this attribute was useless.

    You’re better off, to do some very minor browser sniffing, then cater your code where req’d to a particular browser.

    e.g. if you are trying to set the style attribute via DOM methods… add logic that if the browser is IE, to set the ‘cssText’ attribute instead (since IE doesn’t follow the spec here)

  2. Arjsn Eising says:

    Why testing on JavaScript version? It is better to test if a method or object is present, and then use it.

  3. The idea of testing for methods is good when you’re sure what your baseline is. The problem is that with mobile devices you’re never sure what the baseline is.

    A very nice example is Blackberry (7290 I think) that supports JavaScript but you can’t really know what version/metods – some scripts just don’t work. And I don’t really wish to check for everything I need in a script…

Leave a Reply