Dynamically Assigned Event Handlers
-
Assign a function as an event handler.
-
Dynamically switch functions, change functionality.
-
Define function, assign to handler.
-
Note: the book used a Function, which refers to the
Function object. But this is not correct, you should still use function
as we have in class.
-
Example:
function keypress(e) {
window.alert('Key pressed: ' + String.fromCharCode(e.which));
}
document.onkeypress = keypress;
Really Annoying Events
Home
Internet II: Day 4