Categories:

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.