JavaScript Examples

Source Code HTML Page Description
template.txt template.html basic structure, including 2 types of JavaScript Comments
alert.txt alert.html writes "Hello World!" to an alert box
confirm.txt confirm.html asks a question via a confirm box (does nothing else)
prompt.txt prompt.html asks for your name via a prompt box (does nothing else)
write-0.txt write-0.html writes "1" to the document
write-1.txt write-1.html writes "1" thru "10" to the document
write-2.txt write-2.html writes "1" thru "10" to the document with spaces
write-3.txt write-3.html writes "1" thru "10" with <BR>
write-4.txt write-4.html writes "1" thru "10" with <OL> and Escape Sequence
write-5.txt write-5.html writes "1" thru "10" with <TABLE> and Escape Sequence
function-0.txt function-0.html writes "1" thru "10" with <BR>
function-1.txt function-1.html writes "1" thru "10" using a global variable
function-2.txt function-2.html writes "1" thru "10" using a global and a local variable
function-3.txt function-3.html writes "1" thru "10" using a literal parameter (no global)
function-4.txt function-4.html writes "1" thru "10" using a variable parameter (global)
function-5.txt function-5.html writes "1" thru "10" using 2 parameters (2 local variables)
while-0.txt while-0.html writes "1" thru "10" to the document, via a loop
while-1.txt while-1.html writes "1" thru "10" to the document, auto increment
while-2.txt while-2.html writes "1" thru "10" to the document, auto pre-increment
while-3.txt while-3.html writes "1" thru "10" to the document, auto post-increment
while-4.txt while-4.html writes "10" thru "1" to the document, auto pre-decrement
while-5.txt while-5.html writes "10" thru "1" to the document, auto post-decrement
for-0.txt for-0.html writes "1" thru "10" to the document, via a loop
for-1.txt for-1.html writes "10" thru "1" to the document, auto decrement
for-2.txt for-2.html writes "1" thru "10" to the document, with alert box
for-3.txt for-3.html writes "1" thru "10" to the document using even numbers
for-4.txt for-4.html writes "1" thru number indicated by user to document
for-5.txt for-5.html writes "1" thru number indicated/suggested to document
if.txt if.html decides if the light is green
ifelse.txt ifelse.html decides if the light is green, else red
ifelseif.txt ifelseif.html decides if the light is green, elseif red, else yellow
switch.txt switch.html decides bgColor using Math.random( ) and <META> tag
rollover-0.txt rollover-0.html a rollover using 2 images and object number
rollover-1.txt rollover-1.html a rollover using 2 images, second is an animated .gif
rollover-2.txt rollover-2.html a rollover using 2 images and object name
rollover-3.txt rollover-3.html a rollover using 3 images and object name
rollover-4.txt rollover-4.html a rollover using Functions in <HEAD> section
rollover-5.txt rollover-5.html multiple rollovers using Functions in <HEAD> section
date.txt date.html displays the date in various ways with Escape Sequence
clock.txt clock.html the time in an <INPUT> Text Box/Element via <FORM>
clock-cd.txt clock-cd.html a [Y2K compliant] countdown-clock via <FORM>
form.txt form.html a form with Event Handlers and <SCRIPT>
frame.txt frame.html a frame, <A> Attributes and <FORM> Event Handlers
fib-0.txt fib-0.html complex program, method 1
fib-.1txt fib-1.html complex program, method 2
fib-2.txt fib-2.html complex program, method 2 using a global variable
fib-3.txt fib-3.html complex program, method 2 using a new local variable
fib-4.txt fib-4.html complex program, method 2 using new local variable name
fib-5.txt fib-5.html complex program, method 3 using new local variable name
bj-21.txt bj-21.html BlackJack - 21 ( bj-21.txt is a copy of bj-21.js )