HTML and CSS Reference
In-Depth Information
FORMAT
<script>
JavaScript statements...
</script>
EXAMPLE 2.1
<script>
document.write("Hello, world!<br />");
</script>
Attributes.
The <script> tag also has attributes to modify the behavior of the tag. The
attributes are
• language
• type
• src
Any JavaScript-enabled browser can identify that the scripting language is JavaScript,
if the language attribute is set to JavaScript 2 rather than, for example, VBScript or JScript .
You normally set the language attribute as follows:
<script language="JavaScript">
According to the W3C recommendation, the value assigned to this attribute is an
identifier for the scripting language, but because these identifiers are not standard, this
attribute has been deprecated in favor of the type attribute.
The language attribute can be assigned a version number to specify what version of
JavaScript is supported to view the page. If the browser doesn't recognize the version,
the script will be totally ignored. You shouldn't have to worry about this if you are using
the latest version of a particular browser, but just in case, here's how you specify a ver-
sion number.
< script language="JavaScript1.5" >
</script>
The type attribute is used to specify both the scripting language and the Internet con-
tent type. It is used mainly to validate JavaScript as part of a well-formed document and
is the preferred way to start JavaScript in all modern browsers.
<script language="JavaScript"
type="text/javascript">
</script>
2. Although common to most scripts, the language attribute has been deprecated as of HTML 4.0 in favor of
the type attribute.
 
Search WWH ::




Custom Search