Introduction to programming via JavaScript

JavaScript is a programming language that allows a web page to handle input from a user and can provide customized output.  The language can also perform other more complex operations.

The goal is to meet some basic programming concepts such as objects, properties, methods, variables, and a simple program flow command. The following HTML file contains a scrap of JavaScript that will form the basis for this exploration.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="AUTHOR" content="Dana Lee Ling">
<link href="http://www.comfsm.fm/~dleeling/chocolate.css" rel="stylesheet" type="text/css">
<title>HTML 4.01 Charset ISO 8859-1 Skeleton</title>
</head>
<body>
<h1>Script Scrap</h1>

<script type="text/javascript">
document.write(navigator.appName)
</script>

</body>
</html>

To enter the above script, open the page http://www.comfsm.fm/~dleeling/cis/htmlskeleton.html View the source code for that page.  Add the script to the source code and save the file to your disk.  Then open the file using the Internet Explorer. 

A script is started with the script tag in HTML 4.01. The type specification for HTML 4.01 is different from that of HTML 3.2.  There is an additional specification that the script character set is text.

011114marlinadobe.jpg (14502 bytes)The second line of the script uses the document object. An object can have methods by which a task is accomplished and properties which can be read and, in some cases, set. The second line invokes the write method for the document object to write the application version of the browser to the document. Here the document is the web page itself.

Think of a baby as an object.  The baby has some properties that are read only such as eye color and sex.  The baby has properties that can be both read and set: happy, angry, hurt.  A parent can determine if the baby is happy or angry. A baby can be made happy by tickling it, or made angry by not giving the baby something the baby wants. 

Babies that are old enough to understand basic commands also have methods. Methods might include telling the baby to sleep, or calling the baby to eat.  In other words, the baby object can do things. 

You might think a baby is an odd metaphor for a programming object, but as you progress in your programming you will encounter concepts such as child objects, parent objects, sibling objects, inheritance and objects such as "previousSibling", "nextSibling", and "canhavechildren"!  All of these exist in either the web page document object model or Dynamic HTML.

JavaScript Tutorial for Programmers: http://www.wdvl.com/Authoring/JavaScript/Tutorial/index.html
JavaScript Primer: http://www.javascriptkit.com/javaindex.shtml
JavaScript Tutorials: http://www.javascriptkit.com/javaindex.shtml
JavaScript Learning Center: http://www.javascriptmall.com/learn/

IS 201 Course Page Lee Ling Courses Page College of Micronesia-FSM Home Page