Except where otherwise noted, the contents of this presentation are Copyright 2010 Marty Stepp and Jessica Miller.
| name | description | 
|---|---|
							load,
							unload
						 | 
						the browser loads/exits the page | 
							resize
						 | 
						the browser window is resized | 
							error
						 | 
						
						an error occurs when loading a document or an image | 
							contextmenu
						 | 
						the user right-clicks to pop up a context menu | 
window object.  An alternative to window.onload:
					window.onload = function() { ... };document.observe("dom:loaded", function() { // attach event handlers, etc. });
| name | description | 
|---|---|
							keydown
						 | 
						user presses a key while this element has keyboard focus | 
							keyup
						 | 
						user releases a key while this element has keyboard focus | 
							keypress
						 | 
						user presses and releases a key while this element has keyboard focus | 
							focus
						 | 
						this element gains keyboard focus | 
							blur
						 | 
						this element loses keyboard focus | 
							select
						 | 
						this element's text is selected or deselected) | 
| property name | description | 
|---|---|
							keyCode
						 | 
						
							ASCII integer value of key that was pressed  (convert to char with String.fromCharCode)
						 | 
					
							altKey, ctrlKey, shiftKey
						 | 
						
							true if Alt/Ctrl/Shift key is being held
						 | 
					
							Event.KEY_BACKSPACE
						 | 
						
							Event.KEY_DELETE
						 | 
						
							Event.KEY_DOWN
						 | 
						
							Event.KEY_END
						 | 
					
							Event.KEY_ESC
						 | 
						
							Event.KEY_HOME
						 | 
						
							Event.KEY_LEFT
						 | 
						
							Event.KEY_PAGEDOWN
						 | 
					
							Event.KEY_PAGEUP
						 | 
						
							Event.KEY_RETURN
						 | 
						
							Event.KEY_RIGHT
						 | 
						
							Event.KEY_TAB
						 | 
					
							Event.KEY_UP
						 | 
						
| event name | description | 
|---|---|
							submit
						 | 
						form is being submitted | 
							reset
						 | 
						form is being reset | 
							change
						 | 
						the text or state of a form control has changed | 
activate | 
						clear | 
						disable | 
						enable | 
					
focus | 
						getValue | 
						present | 
						select | 
					
$F("formID")["name"]
				
$F("controlID")
				$F function returns the value of a form control with the given id
				
if ($F("username").length < 4) {
	$("username").clear();
	$("login").disable();
}
					<form id="exampleform" action="http://foo.com/foo.php">...</form>
window.onload = function() {
	$("exampleform").observe("submit", checkData);
};
function checkData(event) {
	if ($F("city") == "" || $F("state").length != 2) {
		alert("Error, invalid city/state.");  // show error message 
		event.stop();
		return false;
	}
}
				stop method on the eventstring.match(regex)
						
							- if string fits the pattern, returns the matching text; else returns 
null 
							- can be used as a Boolean truthy/falsey test:
							var name = $("name").value;
if (name.match(/[a-z]+/)) { ... } 
						
					i can be placed after the regex for a case-insensitive match
						name.match(/Marty/i) will match "marty", "MaRtY", ...string.replace(regex, "text")
						
							- replaces the first occurrence of given pattern with the given text
								
var str = "Marty Stepp";
								str.replace(/[aeiou]/, "*") returns "M*rty Stepp"
							 
						
					g can be placed after the regex for a global match (replace all occurrences)
						str.replace(/[aeiou]/g, "*") returns "Mxrty Stxpp"str.replace(/[aeiou]/g, "*");       // str still "Marty Stepp" !
str = str.replace(/[aeiou]/g, "*");   // str now "M*rty St*pp"
					str = str.replace(/[^A-Z]+/g, "") turns str into "MS"