|
"This JavaScript tutorial is aimed primarily at those who have had at least some exposure to another programming language. It is not our purpose here to cover the basic concepts of computer programming, but rather illustrate the syntax and methodology of JavaScript. For its part, JavaScript is a rather basic language which conforms tightly to the core concepts of computer programming. Any background in programming, from Visual Basic to Pascal to C (which is far more advanced) is sufficient to readily understanding JavaScript.
"Those who are true novices at programming would be better off with any number of available books on JavaScript which take the time to explain both the specifics of the language and programming concepts in general."
Note: This is an older tutorial, which only covers up to JavaScript 1.2, with the corresponding Netscape 4 DOM and Internet Explorer 4 DOM. That said, this is still an excellent introductory tutorial. So just be aware that after completing this tutorial, there are some additional topics which should be looked into-- such as the W3C DOM, and the additional features in newer versions of JavaScript.
>> |
The Versions of JavaScript [New Window] |
Embedding JavaScript
"JavaScript code is typically embedded into an HTML document using the SCRIPT
tag. You are free to embed as many scripts into a single document as you like, using multiple SCRIPT
tags. A script embedded in HTML with the SCRIPT
tag uses the format:
<script type="text/javascript" language="JavaScript">
<!--
document.write("Hello World!");
//-->
</script>
"The LANGUAGE
attribute is optional, but recommended. You may specify that a section of code only be executed by browsers which support a particular version of JavaScript; for instance:
<script type="text/javascript" language="JavaScript1.2">
"Another attribute of the SCRIPT
tag, SRC
, can be used to include an external file containing JavaScript code rather than code embedded into the HTML:
<script type="text/javascript" language="JavaScript" src="corefunctions.js">
</script>
"The external file is simply a text file containing JavaScript code, and whose filename ends with the extension ".js". Note that although some version 3 browsers support the SRC
attribute, it only functions reliably across platforms in the version 4 browsers."
Note: As of the end of 2000, the 4.x browsers finally became "the previous generation" of Web-browser. So it should now be safe to assume that any browser which is configured to support JavaScript should also support the SRC
attribute.
"Scripts can be placed inside comment fields to ensure that your JavaScript code is not displayed by old browsers that do not recognize JavaScript. The markup to begin a comment field is <!--
while you close a comment field using //-->
. This practice is certainly optional, but considered good form when your page is likely to be visited by older browsers. Certainly, as older browsers fade away, this practice will likely become unnecessary."
Note: Good programming practices never go "out of date". And the attention to the little details, like comments around JavaScript code, helps a Website to present a really professional image.
>> |
JavaScript Grammar [New Window] |
>> |
Variables and Data Types [New Window] |
>> |
Operators [New Window] |
>> |
Statements [New Window] |
>> |
Functions [New Window] |
>> |
Objects [New Window] |
>> |
Event Handlers [New Window] |
>> |
Conclusion [New Window] |
* |
E-mail the Webmaster Page Content Updated: January 24, 2003 |
This document is my personal study notes. Not something that was authorized by the author or the publisher of this Web tutorial. Some content from the original site is quoted here, so a few notes and small updates could be added to that original text. All content from the original tutorial remains the property of the original owners. And any notes added to that original content are Copyright © 2002 Allen Smith. All rights reserved, to protect the Copyright of the original (quoted from) work.