Chapter 10 in textbook.
CGI - all cleverness on the server's side of the connectionJavaScript - a way of programming the browser's behaviour
No connection with Java. Name reflects marketing decisions
Comparison with Java:
Example, more short examples.
JavaScript Syntax
References, Tutorials
Literal Values
StringsVariables & Assignment
- enclosed in simple or double quotes
- quotation inside the string must be escaped
Numbers
- integers
- floating point
Logical Values
true
false
References
- objects can refer to each other using references
- no pointers
Comments
//
/* ... */
Type Conversions
- automatic
eval
parseInt
parseFloat
+
operator for strings
if/else
for
while
document.writeln
break
, continue
for .. in
like Perl's foreach
(iterates
over all properties of a JavaScript object)
function
statement
var
(global by default)
(li> you can assign a function to a variable and then use the variable
as if it were the function (example)
length
new
window --+-- frame ... | +-- frame --+-- document --+-- form1 --+-- elem1 . | | . | +-- elem2 . | +-- form2 --+-- elem1 | +-- elem2 | +-- elem3 |
Where description is one of the following: yEvent Description Relevant for onLoad [1] documents, framesets onUnload [2] documents, framesets onSubmit [3] forms onClick [4] radio, check, submit, links onFocus [5] text fields, passwords, etc. onBlur [6] text fields, passwords, etc. onChange [7] text fields, scrolling, select onMouseOver [8] hypertext links onSelect [9] text fields
window
object window
Properties:
window
Methods:
window
Options
document
object document
Properties:
document
Methods:
form
, form elements object(s) form
properties:
form
Element
PropertiesProperty Description Property of name the element's name all value the element's value all checked button checked? check, radio defaultChecked checked by default? check, radio options array of options in a list lists. menus text the text label of a list option list & menu items selectedIndex first selected option lists, menus selected option selected list & menu items defaultSelected selected by default? lists, menus
form
Methods
links
array String
Methods: