Lecture 15 - JavaScript and the DOM - annotated

Lecture 15- - Midterm info JavaScript and the Document Object Model INFO/COM S 230 Intermediate Web Design and Programming Time 7:30-9PM Tuesday

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 JavaScript and the Document Object Model INFO/COM S 230: Intermediate Web Design and Programming Midterm info Time: 7:30-9PM, Tuesday 3/11 Place: Olin 155 Format: On paper Closed book, closed notes However, you can bring a 4”x6” index card of notes you made yourself (front and back). Coverage: Up to (and including) last Monday’s lecture on logins HTML is a tree One (useful) way of thinking about an HTML document is as a “tree” of “nodes”. <html> <head> <title> David P. Wil iamson </title> </head> <body> <div id="content"> <div id=“myimg"> <img src="wil iamson.gif" width="150" height="217" alt="David Wil iamson" /> </div> <p> I am a professor with a joint appointment in the <a href="http://www.orie.cornel .edu">School of Operations Research and Industrial Engineering</a> and the <a href="http://www.cis.cornel .edu">Faculty of Computing and Information Science</a>. </p> </div> </body> </html> The DOM Easy PDF Creator is professional software to create PDF. If you wish to remove this line, buy it now.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 But what’s an “object”? A way of putting together data along with functions that operate on that data. Objects have “fields”/“properties” (the data) and “methods” (functions working on that data). PHP has objects (will discuss later in the course). JavaScript has objects: myobject.mydata; myobject.myfunction(); Your browser represents every node in the tree as an object. The attributes of each tag are properties of the object; the objects have methods that allow easy manipulation. The top-level object is “document”. How do I access the node I want? The document object has methods “getElementByID” and “getElementsByTagName”. E.g. var node = document.getElementByID(“photoid”); var nodearray = document.getElementsByTagname(“img”); What can I do with a node when I have it? You can access other nodes.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2008 for the course INFO 2300 taught by Professor Williamson during the Spring '08 term at Cornell University (Engineering School).

Page1 / 6

Lecture 15- - Midterm info JavaScript and the Document Object Model INFO/COM S 230 Intermediate Web Design and Programming Time 7:30-9PM Tuesday

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online