Javascript Events, Forms & Ajax
Javascript Events, Forms & Ajax
String attribute value vs. function property JS property names always lower case this and scope chain Event handlers return values
Adopted with DOM Level 2, except for Internet Explorer Event object parameter or global and its properties
2 phase propagation: capture and bubble stopPropagation() and cancelBubble preventDefault() and returnValue Handler registration: addEventListener / attachEvent
addEventListener() and useCapture Handler scope: not augmented; this keyword in IE Multiple handlers and duplicate registrations Specialized events (mouse, key) have different properties Synthetic events with dispatchEvent / fireEvent
HTML Forms
validate input values before submit filter keys input (e.g. only digits) dynamically creating select options prepare additional hidden fields
AJAX
HTTP scripting alternatives: img, iframe, script XMLHttpRequest, XDomainRequest and ActiveXObject (Msxml2|Microsoft).XMLHTTP 3 steps: create, send, receive Cross-platform object creation open(method, url, async) and send(body) Asynchronous receiving with onreadystatechange and readyState: status, responseText, responseXML