1. Technology

Your suggestion is on its way!

An email with a link to:

http://javascript.about.com/library/bljver.htm

was emailed to:

Thanks for sharing About.com with others!

What Version of Javascript

Join the Discussion

Questions? Comments?

Javascript like all programming languages (and all programs for that matter) has evolved over time. What this means is that new commands have been added to the language to support additional functionality and make it easier to use Javascript to provide various tasks. At the time of writing the latest release browsers support Javascript 1.6.

Commands introduced in newer versions of the language are only supported when the browser that your visitor is using supports the same or a later version of Javascript than the one in which the command was introduced. If your visitor is using a browser that only supports an earlier version of Javascript then commands that are not recognised in that version will cause unexpected results, may cause the script to crash, or may even cause the browser itself to crash (although this last is unlikely). To resolve this you can either avoid the use of commands only supported by more recent versions of Javascript or test the browser first to see what version is supported.

So how can we determine which version of Javascript a given browser supports? Well Javascript doesn't contain anything that can test for which version is supported but surprisingly HTML does. By combining HTML and javascript together we can set up a Javascript variable containing the version number as follows:

<script type="text/javascript">
var jsver = 1.0;
</script>
<script language="Javascript1.1">
jsver = 1.1;
</script>
<script language="Javascript1.2">
jsver = 1.2;
</script>
<script language="Javascript1.3">
jsver = 1.3;
</script>
<script language="Javascript1.4">
jsver = 1.4;
</script>
<script language="Javascript1.5">
jsver = 1.5;
</script>
<script language="Javascript1.6">
jsver = 1.6;
</script>
<script type="text/javascript">
document.write('<p><b>Javascript version ' + jsver
+ ' supported<\/b><\/p>');
</script>

The following paragraph is produced by the above code to tell you what version of Javascript your browser supports.

If the above message doesn't say that your browser supports version 1.6 then you might consider upgrading your browser to one that does. The following lists which version of Javascript the more recent versions of the more common browsers support.

  • Firefox, Netscape 7/8, Mozilla, and Opera 7+ all support version 1.6
  • Netscape 6 supports version 1.5
  • Opera 6 supports version 1.4
  • Netscape 4.5, Opera 5, and Internet Explorer 6 support version 1.3
  • Netscape 4 supports version 1.2

Of course I haven't gone into what commands are supported by which version of Javascript, I will deal with that in future articles.

©2014 About.com. All rights reserved.