AJAX-Tips Tutorials
AJAX-TipsLanguage Attribute
The language attribute in JavaScript is probably one of the most ignored attribute in an Ajax based application. This form of attribute has become so familiar that developers have started to ignore it.
The language attribute in JavaScript may just look like a simple command for the browser but without it, the application will not work. This basic function will practically set the stage for other codes to be interpreted in the browser.
As JavaScript and Ajax increases its functionality, the importance of properly using language attribute in these types of application is also realized.
The language attribute maybe the first Ajax or JavaScript based code learned by developers. It is written before every other script in the online application.
The attribute goes this way:
<script language="javascript">
The above script will practically inform the browser that the following scripts written will be in JavaScript.
You may once in a while bump into a code that goes this way:
<script type="text/javascript">
This form of JavaScript is called the “type attribute.” The coding will dictate the language the browser should expect (JavaScript) and how the script is written (in plain text). Other variations could be possible in this form of attribute so that it could provide more information to the browser.
Special Feature of Language Attribute
JavaScript has already been used in software and website development for more than a decade now. Although familiarity with JavaScript is not strong at the start, the emergence of Ajax as the Web 2.0 programming technique, the information on JavaScript has never been so useful today.
For that reason, the language attribute is slowly being dropped by some developers. This is often implemented in small applications since changing this setting in case something goes wrong is easy.
So instead of the usual language attribute that goes this way:
<script language="javascript">
Developers could just use this:
<script>
This convenience is actually tempting but as already indicated, this option is only recommended if your website is very light and changes could be done in an instant.
Varieties of Implementation
There are options for developers who wanted to do more in their language attribute. Instead of using the simple coding, developers could specify the version of JavaScript they will be using. This is very useful for developers who wanted to increase the troubleshooting ability of the browser.
By defining the version of JavaScript, developers could be alerted by the browser that their application can’t be read because of browser incompatibility.
<script language="javascript1.5”>
The code above assumes that you are coding with JavaScript version 1.5. Since we are already in 2.0, you can just change the 1.5 into the appropriate version.
Take note that this will not be used to force the browser to read the JavaScript coding no matter what version it is. The browser is still confined with the JavaScript version it’s supposed to read.
The language attribute may just be a simple code. But when they are expanded correctly, developers could use this small tool to improve their Ajax based application.
Sponsored Links
