Categories:
Partners
Web Hosting
We've partnered with HostGator for reliable, affordable hosting starting at $3.95/mon. Use coupon code "javascriptkit25" for 25% off any package.

Using the language attribute of JavaScript

The basic form of the language attribute is very easy to implement. Simply shove in the keyword "language=", followed by "JavaScript", into your <script> tag:

<script language="JavaScript">
alert("hi!")
</script>

The above declaration does more than simply tell you and I that the containing code is written in JavaScript- it tells the browser as well. This is very important to realize, although up until now, it was also optional. Due to the dominance of JavaScript over other languages from the start, all browsers since NS 2.x default to the language "JavaScript" when no language attribute is explicitly defined. Therefore, your browser treats:

<script>
alert("hi!")
</script>

exactly the same as the first code- as a JavaScript code. Having said that, you may begin to ask: "Could there be that there exist other languages other than JavaScript for my web browser?" Your suspicion is correct. More on this later.

Copyright 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.