Beginning HTML, XHTML, CSS and JavaScript - Code Examples

Back to main book index

Chapter 11: Learning JavaScript

Here are the examples for Chapter 11, which introduces JavaScript.

ch11_eg01.htmlA first JavaScript using the document.write() method
ch11_eg02.htmlTry It Out - Text from an external file
ch11_eg03.htmlAccessing form data
ch11_eg04.htmlChanging information on the page (a simple image rollover)
ch11_eg05.htmlCalling a function (to calculate the area of a rectangle)
ch11_eg06.htmlIf conditional statement (only says Good Morning if the clock on your computer is before 12 am - otherwise blank).
ch11_eg07.htmlIf Else conditional statement If (Good morning or Good afternoon)
ch11_eg08.htmlSwitch conditional statement
ch11_eg09.htmlWhile Loop
ch11_eg10.htmlDo While Loop
ch11_eg11.htmlFor Loop
ch11_eg12.htmlThe break statement
ch11_eg13.htmlString object - big() method and length property
ch11_eg14.htmlMaking a substring uppercase
ch11_eg15.htmlDate object (days of the year left)
ch11_eg16.htmlMath object
ch11_eg17.htmlArray object
ch11_eg18.htmlWindow object

Exercises

Exercise 15 times table
Exercise 2Time of day