Java Script Lesson 1 - The Basics
If you are tired of putting up plain HTML pages and you are ready to inject a little life into them, this next series of JavaScript tutorials will help you accomplish this goal. First, we will begin with the basics so that you have a working idea of how JavaScript enhances HTML and what it can do for your site.
JavaScript was developed by Netscape as a way to bring stagnant HTML pages to life by adding a variety of effects and tools to help your pages come to life. It is very simple to learn and implement, as we will demonstrate in this series of tutorials.
If you are concerned about cross platform compatibility, especially since Netscape developed JavaScript, Internet Explorer can handle just about 99% of all JavaScripts. Unlike many scripting languages, you should not have to create two versions of the same script to get it to work on all browsers.
First, whenever you insert JavaScript into your pages, you will need to begin your script with:

This tells a browser that there is a JavaScript located in the HTML page.
The next important code to note is:
< ! – - at the beginning of your script
and
// – -> at the end of the script. If you insert these two tags you will ensure that older browsers will not display your JavaScript code inside your page.
Much like HTML, you can insert comments into your JavaScript, which can be useful for including creator information, or simply placing reminders for yourself. To add a one line comment in JavaScript, you would add:
// This is a one line comment.
For more than one line, you would need to add: /* at the beginning of your comment and */ at the end. For example:
//Our one line comment
/*Has grown to two lines */
If you put all of these together, you would end up with:

Now isn’t simple? Of course, the above script is not an actual script, it is just showing you how comments and the basic formatting of JavaScript work. You are now ready to move beyond the basics and start learning more about how you can use JavaScript on your own site.
Our next tutorial will get you started on objects, which are what JavaScript uses to perform its tasks.
Related Posts:Posted on 12/27/05 1:42 AM
Be the first to comment!