★ wanayoo — archive 1999 http://javascript.about.com/compute/javascript/library/weekly/aa091199.htmNouvelle recherche | Portail wanayoo
   You are here:    About.com > Computing/Technology > Focus on JavaScript > Articles
spacer
shadow
shadow
spacer Home
Fri, Mar  3,  2000
spacer
graphic
Join Free
Your Guide Nate Kassebaum - your About.com Guide to:
Focus on JavaScript

Content: Welcome | Netlinks | Articles | Guide Bio | Search | Related
TalkAbout: Forums | Chat | Events | Newsletter | Share This Site | Join
Shopping: ShopNow | Books | Videos | Jobs | ShoppingAbout

What is JavaScript?

Dateline: 09/11/99

Dynamic!  Interactive!

I keep hearing these buzzwords, but what do they mean?  What do I need to make my Web site "dynamic" and "interactive?"

The answer to this question and many more is "JavaScript."  So just what is JavaScript?

JavaScript is an extension of HTML that allows the programmer to do things with the Web page as it is displayed to the user.  Where HTML is the skeleton that gives a document its appearance and structure, JavaScript is the brains and the muscles that give a page life.

JavaScript is not Java.  Java is full-fledged, compiled (sort-of) application development language.  Java makes applications that can function on their own (sort of like Microsoft Word) or mini-applications called "applets" that can run inside of a web browser.  If you're looking for Java, visit About.com's Java Web site.

Why does JavaScript sound like Java?  JavaScript got the "Java" in its name because its syntax is based on Java.  In other words, most statements in both languages are written in a similar manner.  

Where does JavaScript go?  As I said before, JavaScript is an extension to HTML.  This means that the JavaScript code goes right in with the HTML code.  JavaScript code goes between the <script> tag, like so:

<script>
... JavaScript code goes here ...
</script>

The <script> tag has a couple of different options, but most important is the "language" option.  Since some browsers can interpret different types of script code (such as VBScript), you should always specify language="JavaScript" when you are using JavaScript.

<script language="JavaScript">
... code ...
</script>

Another trick to note is that older browsers (Netscape 1.X, Internet Explorer 2.X) do not support JavaScript and do not recognize the <script> tag.  These older browsers will ignore the <script> tag and simply display the JavaScript code as if it were regular text on the page.  To avoid this, surround your JavaScript code with comment tags like so:

<script language="JavaScript"><!--
... code ...
// --></script>

This way, if the browser doesn't recognize the <script> tag, it will ignore everything between the <!-- and the --> tags.  Browsers that do recognize the <script> tag are aware of this little trick, and they will ignore the <!-- and the --> tags, but will still interpret the JavaScript code.  (Note: the // in front of --> is very important.  Do not leave this out.)

JavaScript makes web pages dynamic and interactive primary through something called the Document Object Model (DOM).  The DOM is a way of simplifying the structure of an HTML document so that it can be easily understood and accessed by mere mortals.

The DOM represents the HTML document as "objects."  It's difficult to describe an object as anything other than an object: an object is just a thing that has properties and can contain other objects.  As an example, there is an object called "document," that represents the HTML document.  If your HTML looks something like this:

<html>
<body>
<form name="myForm">
<input type="text" name="myText">
</form>
</body>
</html>

Then the "document" object would contain an object called "myForm."  You can access the "myForm" object by using "document.myForm."  "myForm" contains an object called "myText," which can be accessed using "document.myForm.myText."  If we wanted to set the value of the "myText" textbox to say "hello," we would use the following JavaScript code:

document.myForm.myText.value = "hello";

Through this method, we can modify nearly every aspect of our HTML document on the fly.  To find out some of JavaScript's uses, visit Uses for JavaScript.  For some beginner's tutorials, visit Getting Started.

Visit the message boards!

Previous Features

About.com Related About.com GuideSites
  • Focus on Java
  • Focus on Web3D
  • HTML
  • Intranets
  •  
  • Perl
  • Personal Web Pages
  • Web Design
  • XML
  •  
    About.com Elsewhere on About.com
    What's New, What's Hot
  • Breaking News
  • Decorate Your Dorm Room
  • Conquer Jet Lag
  •   JustAbout
  • Quit Smoking
  • Healthy Living
  • Twisted Travel

  • search Search
      
    This Site About.com
    Share This Site With a Friend (enter their email address below):

       

    Top of Page

    spacer
    In Partnership With TechWeb
    TechWeb News
     TechWeb News
    Real-Time OS Falls As Wind River Consolidates

    Linux Suppliers Focus On Improved Security

    Software Integrators Embrace CRM
    Top Downloads
     Free Downloads
     


    Marketplace

    ShoppingAbout

    Find a Friend BookStore Build a Web Page Finance Channel Send a card! Sweepstakes
    shadow
    shadow

    shadow
    shadow

    © 2000 About.com, Inc. All rights reserved.
    ©   2000 About.com, Inc. "MiningCo.com" and "About.com" are trademarks of About.com, Inc.,
    a publicly traded company listed on NASDAQ under the symbol "BOUT."
    For more information on About.com, visit Our Story, Be a Guide, Be an Advertiser, or Investor Relations.
    For rules of use, read our User Agreement; for privacy concerns, read our Privacy Policy.
    Having a Problem? Report it here.