JavaScript Tutorial - Hello World!

Left
Right

The first program to run is the famous Hello World! program.
If you can run this, then you have overcome many issues regarding

  • How to write a program to file
  • How to run a program
  • How to see the output from a program
Go to your public_html directory in your home directory, and type gedit hello.html (on Linux) to pop up a simple graphical editor that understands all the special keys found on the keyboard. (The text is below.)

For MS-windoze users, you would probably use the scratchpad file editor. But I have no idea where to put the file - in the root directory of your hard-drive is the easiest.

<HTML>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
document.write("<H1>Hello World!</H1>");
</SCRIPT>
</BODY>
</HTML>

Pop up a Netscape browser and enter something like:
http://owen.sj.ca.us/~rk/howto/javascript/work/hello.html
where ~rk is your user name and after it is the path leading down to your hello.html file relative to the public_html directory. If it's in your public_html directory then no path needs to be given.

For other browsers, and non-owen students, you can use the special "file://localhost/path/to/file/hello.html" URL to test and show your work, and all browsers have some way to view a file.

If you see a Hello World! then you were successful. If not, then get help from your teacher.

Use the hello.html as a template for later assignments.

Left
Right
Slide 2