JavaScript Programs
Where the JavaScript Goes Information
about CDATA or separate files.
NOTE that in HTML5 you do NOT need to enclose the scripts with CDATA.
Each example comes in two versions. The versions linked to on this page do not
use CDATA and a file with _poly appended to the end does use CDATA. For example
there are files functions1.html and functions1_poly.html
NOTE also that in HTML5 the script tag does NOT require the lang attribute, but some
earlier versions of HTML did, so I have included it.
- functions1.html,
functions1wExternalJS.html
TestBrowser.html, TestBrowserWithComments.html, TestBrowserWithComments2.html
<script language="javascript">
CDATA or external files for the JavaScript
hiding JavaScript from old browsers inside comments
function notation and parameters
alert( )
- functions2a1.html
, functions2a2.html, functions2a3.html
, makeChange.html
variables - defining and changing their values and types
returning a value from a function
prompt( ) and parseInt( )
concatenation vs. addition - overloading of operators
document.write( )
- doc_write.html,
doc_write_revisted.html
including HTML tags, single and double quotes
including images
document.write(string1,string2) etc. form
multiple document.writes vs. assembling one long string
- arith_funtions1.html, arith_functions_2.html
functions for adding, multiplying etc. one and two variables
- CoerceTypes.html,
TypeConversion_properlyDone.html
stings and numbers (integer, float) and + operator
how to convert between strings and numbers
- GlobalChange,
moreGlobalChange Scope_of_Vars
local and global variables
- miniTable.html
how to write out a table in document.write( )
- rounding.html
how to get floating point numbers rounded and
how to print out to a certain number of decimal places