14 DOMTimers
14 DOMTimers
CS380
Problems with JavaScript
2
CS380
Prototype framework
3
<script src="
https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/pr
ototype.js "
type="text/javascript"></script> JS
$("id") JS
$("footer").innerHTML = $("username").value.toUpperCase();
JS
CS380
DOM element objects
5
CS380
DOM object properties
6
// bad style!
var paragraph = document.getElementById("welcome");
paragraph.innerHTML = "<p>text and <a
href="page.html">link</a>"; JS
CS380
Adjusting styles with the DOM
9
CS380
Unobtrusive styling
11
function delayMsg() {
setTimeout(booyah, 5000);
$("output").innerHTML = "Wait for it...";
}
function booyah() { // called when the timer goes off
$("output").innerHTML = "BOOYAH!";
} JS
CS380
setInterval example
14
CS380
Passing parameters to timers
15
function delayedMultiply() {
// 6 and 7 are passed to multiply when timer goes off
setTimeout(multiply, 2000, 6, 7);
}
function multiply(a, b) {
alert(a * b);
} JS
CS380
Common timer errors
16
CS380