JavaScript 1.3 Overview, Part II: Specifying the JavaScript Version - Doc JavaScript | WebReference

JavaScript 1.3 Overview, Part II: Specifying the JavaScript Version - Doc JavaScript


Specifying the JavaScript Version

You can use the LANGUAGE attribute of the SCRIPT tag to specify the version of JavaScript that the script complies with. In fact, we use it all the time to distinguish between different versions of JavaScript. The line <SCRIPT LANGUAGE="JavaScript1.2"> directs the browser to interpret the script only if the version of JavaScript is 1.2 and to ignore the script if the version is higher than 1.2. Specify the JavaScript version if your script includes features that are not supported by other versions.

The default behavior for Netscape Navigator is to support the latest version of JavaScript that is supported by the browser. The latest version of JavaScript supported by Navigator 4.06 and 4.5 is 1.3. Therefore, the line <SCRIPT> is equivalent to <SCRIPT LANGUAGE="JavaScript1.3"> for these versions of Navigator.

To be html compliant (validator.w3.org) which we are switching over to, you need to add TYPE="text/javascript" to the script tag. So, the line

<SCRIPT LANGUAGE="JavaScript1.2">

becomes:

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">

The following table reviews the history of JavaScript tags and identifies the browsers that supported them

Navigator VersionExecutes Code WithinIgnores Code Within
Earlier than 2.0No support for JavaScriptNo Support for JavaScript
2.0LANGUAGE="JavaScript"LANGUAGE="JavaScript1.1"
LANGUAGE="JavaScript1.2"
LANGUAGE="JavaScript1.3"
3.0LANGUAGE="JavaScript"
LANGUAGE="JavaScript1.1"
LANGUAGE="JavaScript1.2"
LANGUAGE="JavaScript1.3"
4.0-4.05LANGUAGE="JavaScript"
LANGUAGE="JavaScript1.1"
LANGUAGE="JavaScript1.2"
LANGUAGE="JavaScript1.3"
4.06-4.5LANGUAGE="JavaScript"
LANGUAGE="JavaScript1.1"
LANGUAGE="JavaScript1.2"
LANGUAGE="JavaScript1.3"
No Tags are ignored

http://www.internet.com


Created: September 28, 1998
Revised: September 28, 1998

URL: http://www.webreference.com/js/column26/version.html