CSE3325 : Javascript, Part 3


In the previous lecture:

In this lecture:


Reference:

Same as the previous lecture:

 

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

    • Events maybe triggered at timeouts.

    • Call setTimeout() to specify that a timer event will occur after a specified number of milliseconds have elapsed.

    • setTimeout("closePodBayDoorsHAL();", 10000) // Call routine in 10 sec.

    • To make a timeout event recur (as you'd do to create an animation)...

      function animate() { changeImage(); setTimeout("animate();", 500); }

    • Timeouts can be cancelled: clearTimeout()

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

clearTimeout(X); // clear a specific timer

 




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.

 



This lecture's key point(s):


CSE3325 courseware | CSE3325 lecture notes

©Copyright Alan Dorin & Jon McCormack 1999,2000