FIT3084: JavaScript, Part 2


In the previous lecture:

Javascript syntax and applications summary

In this lecture:

Working with JavaScript: objects, and events


Reference:

Using JavaScript

  1. Insert JavaScript code between <SCRIPT> and </SCRIPT> tags to be run as the document is loaded.



  2. Use the <SCRIPT> and </SCRIPT> tags to reference a JavaScript .js file

  3. Define event handlers

  4. Define Timer Events

var X = setTimeout("doSomething();", 100);
var Y = setTimeout("doSomethingElse();", 105);

clearTimeout(X); // clear a specific timer

* The event handler registration method discussed here is associated with what is known as the DOM 0 event model. This is widely used and supported, despite the fact that there is a newer DOM 2 event model (which is more complex and not covered in these notes).



JavaScript Windows




JavaScript Object Hierarchy




JavaScript Examples

These simple examples illustrate some of the ways JavaScript can be used. From simple building blocks, medium programs can be built for all kinds of purposes.

Dynamically controlling navigation

 

link to top


Dynamic Page Construction

The current window location can be found using JavaScript and written into the document source as it loads! (As can a lot of other stuff actually.)

Animation

See the source code and note the use of...

prompt() to fetch a URL, window.open( ), onLoad(), the Date object, setTimeout( ),
use of new Array(), document image source access, animation, setting text entry box value, window.close()

Form processing or computation




This lecture's key point(s):


Courseware | Lecture notes

©Copyright Alan Dorin 2009