2. About Me
var presenter = {
name: "Lim Borey",
workAt: "Yoolk Inc.",
email: "lim.borey@gmail.com",
twitter: "@limborey",
communities: [
"ShareVisionTeam",
"Pailin"
]
};
3. DOM Overview
• DOM: Document Object Model - popular way of
representing XML documents
• Implemented in many languages:
o Java,
o Perl,
o PHP,
o Ruby,
o Python,
o JavaScript
o …
• was constructed to provide an intuitive way for
developers to navigate an XML hierarchy
4. DOM Overview
<table border="2">
<tr>
<td>cell is row 0 column 0</td>
<td>cell is row 0 column 1</td>
</tr>
<tr>
<td>cell is row 1 column 0</td>
<td>cell is row 1 column 1</td>
</tr>
</table>
6. Waiting for the HTML
DOM to Load
• HTML is parsed.
• External scripts/style sheets are loaded.
• Scripts are executed as they are parsed in the
document.
• HTML DOM is fully constructed.
• Images and external content are loaded.
• The page is finished loading.
16. Event
• an action that is fired (initiated) within a web page.
• JavaScript is Single Thread
• JavaScript uses asynchronous callback
What you’d see if JavaScript were A representation of using callbacks
able to handle threads to wait for the page to load
20. The Event Object
• Contains contextual information about the current
event
• an object that’s provided, or is available, inside of
every event handler function
• W3C Standard Browser: e
• Internet Explorer: window.event
textArea.onkeypress = function(e){
e = e || window.event;
return e.keyCode != 13;
};
21. Cancel Bubbling
• W3C Standard Browser
e.stopPropagation()
• Internet Explorer
window.event.cancelBubble()
22. Overriding Browser
default event
• W3C Standard Broswer:
e.preventDefault();
• Internet Explorer
window.event.returnValue = false;
23. References
• Pro JavaScript™ Techniques, John Resig
• http://www.howtocreate.co.uk/tutorials/javascript/
domstructure
• https://developer.mozilla.org/en/Traversing_an_HTM
L_table_with_JavaScript_and_DOM_Interfaces