Please note that this page is intended to show only the basic JavaScript features used in CSCI 115.
<script> // Global variables . . . // functions . . . function init() { . . . // Event handlers . . . } window.onload = init; </script>
Event handlers must be placed inside the braces for the init function.
document.getElementById("sourceId").onwhatever = function()
{
document.getElementById("target1").style.color = "red";
document.getElementById("target1").innerHTML = "new content";
document.getElementById("target1").src = "new iamge file";
. . .
}
document.getElementById('someId');
alert('someString');
var whatever;
whatever = prompt('someString');
timerVariable = setTimeout("some function call", 1000);
timerVariable = setInterval("some function call", 50);
clearTimeout(timeVariable);
clearInterval(timerVariable);