




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





CSCI 3110 Advanced Topics in Web Development
Models document (XHTML, XML, etc.) in a hierarchical structure. Allows programmatic parsing and changing of the document. Multiple "methods of attack" of varying complexity. Docsity.com
A document is a collection of nodes of varying type. Nodes can contain other nodes.
This is text.
**Element node** —XHTML tag **Text node** —textual content of document. Contained within element nodes. **Attribute node** —provides more information about an element.Hello
Hi there!
Document Element: html Element: head Element: body Element: title Text: Hello Element: p Text: Hi there! Docsity.com
element.getAttribute(attribute) —returns attribute value for the element http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-3.htm element.setAttribute(attribute, value) —sets/resets the attribute value for the element http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-4.htm http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-5.htm http://webbugtrack.blogspot.com/2007/08/bug- 242 - setattribute-doesnt-always-work.html
An element node's text can be read and modified using the innerHTML property. http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-6.htm innerHTML sees/sets the entire contents of the specified element, including other embedded tags/elements. http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-7.htm Docsity.com
In the context of DOM, an element is an object. It may or may not have a toString method defined. http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-8.htm http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-9.htm
All nodes in a document are related. Relationship types: Child Parent Sibling Each node has a property childNodes which contain an array-like list of children. http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-10.htm This list contains all types of nodes, not just element nodes. http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-11.htm Docsity.com
New elements can be added to a document by creating a new elements, building its contents, and adding it where appropriate in the document hierarchy. element .appendChild(element) http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-15.htm
DOM events can be added to elements: http://en.wikipedia.org/wiki/DOM_events Have event handler return false to prevent further default event handling. http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-16.htm http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-17.htm Docsity.com
The document object contains arrays (as properties) to each access to certain page elements: document.anchors —all named anchors within a document document.forms —all forms within a document document.images —all images within a document document.links —all hyperlinks within a document http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-18.htm
The document object contains properties to each access to certain page elements: body —reference to body element cookie —sets/reads cookies associated with document domain —domain name for current document lastModified —date/time document last modified referrer —URL that referred to current document title —title of current document URL —URL of current document http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-19.htm http://einstein.etsu.edu/~pittares/CSCI3110/examples/8-20.htm Docsity.com