JavaScript topics covered:
  1. JavaScript code needs to be inserted between <script></script> tags. To write the text string "Hello World" to the browser window using JavaScript, use the document.write() method.
    document.write("Hello World");
    Click here to see the example

  2. Add HTML to the text string to get the desired effect.
    document.write("<h1 align='center'>Hello World</h1>");
    Click here to see the example

  3. Any Style Sheets that are on the page will still work with text written to the screen using JavaScript.
  4. Add a comment in JavaScript using // before the comment. To add a block of comments, use /* at the beginning of the comment and */ to end the comment block.

  5. By using document.writeln() method, a line feed and carriage return is added at the end of a line. However, you must use the <pre></pre> tags to surround the document.writeln() statements, otherwise the line feed and carriage return will appear to not work.

  6. For code that will be repeated on several pages, like copy right information, create a source file and insert the code into HTML pages. When the information is updated, it is reflected on all pages. Making maintenance much easier.
    Important: the source file cannot contain the <script></script> tags and can only contain JavaScript statements.
    document.write("<img src='../images/character0.gif' width=100 height=100 alt='' border='2'>");

  7. insert the JavaScript source file above into the HTML document with Script tags.
    <script src="copyright.js" language="javascript">
    Click here to see the example

  8. The alert() method displays a pop-up message to the user. If you have ever filled out an order form on the web, and forgot to fill in a field, you will usually get a pop up message warning that you have forgotten to complete the form. This is done with the alert() method. The alert() method will display what ever is within the parenthesis (). The example below will display "I am here" within the pop up alert box.
    alert("I am here");
    Click here to see the example
    ** Note The alert() method is a useful debugging tool that will be used throughout the course. **

  9. The web browser parses the HTML document line by line and renders the code to the screen. So, what ever is at the top of the HTML document is displayed first. However, if you have an alert, the code waits for the user to click the OK button before continuing. Click here to see the example