spacer
Yehuda Shiran January 27, 2000
Hiding New Features
Tips: January 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

When a new JavaScript version is released, new features are introduced with it. When using these features, you have to hide them from older versions of JavaScript. The cumbersome way is to remember which browser versions were released with the new JavaScript version, and to hide the new features from older versions of these browsers. It is much simpler just to specify the new JavaScript version in the <SCRIPT> tag. Only JavaScript engines matching this version will interpret the code. Older versions of JavaScript engines will just ignore this tag, and will not interpret the JavaScript section. The following JavaScript code will be processed only by JavaScript engines of 1.3 and up:

<SCRIPT LANGUAGE="JavaScript1.3">
<!--
 function handleClick() {
   alert("This browser supports JavaScript 1.3 and up");
}
document.write('<FORM NAME="jukebox">Hit the button:<INPUT TYPE="button" ID="display" VALUE="Demo 1.3" onclick="handleClick()">');
// -->
</SCRIPT>

You should see a Demo button here:

If you don't see the button, your browser does not support JavaScript 1.3. The following code will be exercised only when JavaScript 1.4 comes along:

<SCRIPT LANGUAGE="JavaScript1.4">
<!--
 function handleClick() {
   alert("This browser supports JavaScript 1.4 and up");
}
document.write('<FORM NAME="jukebox">Hit the button:<INPUT TYPE="button" ID="display" VALUE="Demo 1.4" onclick="handleClick()">');
// -->
</SCRIPT>

You should see a Demo button here when JavaScript 1.4 is out:

Many features have been introduced in JavaScript 1.3. Learn more about them in Column 25, JavaScript 1.3 Overview, Part I, and Column 26, JavaScript 1.3 Overview, Part II.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business