Set a variable to determine what version of JavaScript we support : JavaScript Version « Development « JavaScript DHTML






Set a variable to determine what version of JavaScript we support


/*
Examples From
JavaScript: The Definitive Guide, Fourth Edition

Legal matters: these files were created by David Flanagan, and are
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and
distribute them for any purpose.  Please note that these examples are
provided "as-is" and come with no warranty of any kind.

David Flanagan
*/
<html>

<!-- Set a variable to determine what version of JavaScript we support. -->
<!-- This technique can be extended to any number of language versions. -->
<script language="JavaScript"> var _version = 1.0; </script>
<script language="JavaScript1.1">  _version = 1.1; </script>
<script language="JavaScript1.2">  _version = 1.2; </script>

<!-- Run this code on any JavaScript-enabled browser.  -->
<!-- If the version is not high enough, display a message. -->
<body>
<script language="JavaScript">
  if (_version < 1.1) {
    document.write('<hr><h1>This Page Requires JavaScript 1.1</h1>');
    document.write('Your JavaScript 1.0 browser cannot run this page.<hr>');
  }
</script>
</body>
<!-- Now run the actual program only on JavaScript 1.1 browsers. -->
<script language="JavaScript1.1">
    // The actual JavaScript 1.1 code goes here.
</script>
</html>


           
       








Related examples in the same category

1.Check whether JavaScript 1.2 is supported
2.Using Multiple Versions of JavaScript with the language Attribute
3.Using the 'noscript' Tag
4. Testing Different JavaScript Versions
5.Multiple Script Versions
6.Employing the 'NOSCRIPT' Tag
7.Rendering Different Content for Scriptable and Nonscriptable Browsers
8.Hiding Scripts from Older Browsers
9.JavaScript 1.2 is supported, extract a new URL from the portion
10.A simple 'sniffer' that determines browser version and vendor
11.Variable for Browser version and vendor
12.Get IE Version Number
13.Get NN (Netscape Navigator) Version Number