Difference between revisions of "A Simple JavaScript Example"

From Techotopia
Jump to: navigation, search
Line 8: Line 8:
 
<html>
 
<html>
 
<head>
 
<head>
<title>My First JavaScript Example
+
  <title>My First JavaScript Example
 
</head>
 
</head>
 
<body>
 
<body>
 
<script type="text/javascript" language="JavaScript">
 
<script type="text/javascript" language="JavaScript">
document.writeln( "Hello World" );
+
  document.writeln( "Hello World" );
 
</script>
 
</script>
 
</body>
 
</body>
 
</pre>
 
</pre>

Revision as of 15:44, 9 April 2007

No programming book would be complete without an initial example application just to get the reader started, and this book is no exception. In addition to a quick confidence boost for the novice this serves as a good opportunity to check that the environment being used for the rest of this book is fully functional.

Ever since the first book on programming for the C language was published it has become traditional that the first example consists of writing code to display the words "Hello World". With this tradition in mind we will begin with such as example.

Using your favorite editor create an HTML file with the following content:

<html>
<head>
   <title>My First JavaScript Example
</head>
<body>
<script type="text/javascript" language="JavaScript">
   document.writeln( "Hello World" );
</script>
</body>