browsers and the dom csi 3140 www structures, techniques and standards
TRANSCRIPT
![Page 1: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/1.jpg)
Browsers and the DOM
CSI 3140
WWW Structures, Techniques and Standards
![Page 2: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/2.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Overview
The Document Object Model (DOM) is an API that allows programs to interact with HTML (or XML) documents
In typical browsers, the JavaScript version of the API is provided via the document host object
W3C recommendations define standard DOM
Several other browser host objects are informal, de facto standardsalert, prompt are examples
![Page 3: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/3.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Example: “Rollover” effect
Cursor not over image Image changes when cursormoves over
![Page 4: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/4.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
![Page 5: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/5.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
ImportJavaScriptcode
![Page 6: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/6.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Default language for scripts specified as attribute values
![Page 7: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/7.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Calls to JavaScriptshow() function whenmouse moves over/awayfrom image
![Page 8: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/8.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Notice that id of image is first argument to show()
![Page 9: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/9.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
![Page 10: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/10.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
DOM method returning Object
![Page 11: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/11.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Returns instanceof Element(DOM-definedhost object)representingHTML elementwith given id
![Page 12: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/12.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Some properties of Element instance correspondto attributes ofHTML element
![Page 13: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/13.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Method inherited by Element instancesfor setting value of an attribute
![Page 14: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/14.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Effect: src attribute of HTML element withspecified eltId is changed to specified URL
![Page 15: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/15.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Introduction
Image src changed toCFP22.png when mouseis over image,CFP2.png when leaves
![Page 16: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/16.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM History and Levels
Very simple DOM was part of Netscape 2.0Starting with Netscape 4.0 and IE 4.0,
browser DOM API’s diverged significantlyW3C responded quickly with DOM Level 1
(Oct 1998) and subsequently DOM Level 2
We cover JavaScript API for DOM2 + some coverage of browser specifics
![Page 17: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/17.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Intrinsic Event Handling
An event is an occurrence of something potentially interesting to a script:
Ex: mouseover and mouseout eventsAn HTML intrinsic event attribute is used
to specify a script to be called when an event occurs
Ex: onmouseover Name of attribute is on followed by event name
![Page 18: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/18.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Intrinsic Event Handling
![Page 19: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/19.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Intrinsic Event Handling
![Page 20: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/20.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Intrinsic Event Handling
![Page 21: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/21.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Intrinsic Event Handling
Intrinsic event attribute value is a script; what language is it written in?HTTP Content-Script-Type header field
specifies default scripting languagemeta element allows document to specify
values as if they were header fieldsHeader field name Header field value
![Page 22: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/22.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Changebackground colorof elementcontaining cursor
![Page 23: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/23.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
![Page 24: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/24.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Like rollover, style needs to be modifiedboth when entering and exiting the element.
![Page 25: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/25.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Reference to Element instancerepresenting the td element
![Page 26: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/26.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
![Page 27: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/27.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Reference to Element instance
![Page 28: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/28.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
All Element instances have a style propertywith an Object value
![Page 29: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/29.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Properties of style objectcorrespond to CSS style properties ofthe corresponding HTML element.
![Page 30: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/30.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Rules for forming style property names from names of CSS style properties:
If the CSS property name contains no hyphens, then the style object’s property name is the sameEx: color color
Otherwise, all hyphens are removed and the letters that immediately followed hyphens are capitalizedEx: background-color backgroundColor
![Page 31: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/31.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Net effect: “silver” becomes the specified value forCSS background-color property of td element;browser immediately modifies the window.
![Page 32: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/32.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Alternative syntax (not supported in IE6/7/8):
![Page 33: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/33.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Alternate syntax (not supported in IE6/7/8):
Every DOM2-compliant style objecthas a setProperty() method
![Page 34: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/34.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Alternate syntax (not supported in IE6/7/8):
CSS property name(unmodified)
CSS propertyvalue
Empty stringor“important”
![Page 35: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/35.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Advantages of setProperty() syntax: Makes it clear that a CSS property is being set
rather than merely a property of the style object
Allows CSS property names to be used as-is rather than requiring modification (which can potentially cause confusion)
BUT lack of IE support makes it difficult to use (works with FF & Chrome)
![Page 36: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/36.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Modifying Element Style
Obtaining specified CSS property value:
Alternate DOM2 syntax (not supported by IE6/7/8):
![Page 37: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/37.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree
Recall that HTML document elements form a tree structure, e.g.,
DOM allows scripts to access and modify the document tree
![Page 38: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/38.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
There are many types of nodes in the DOM document tree, representing elements, text, comments, the document type declaration, etc.Every Object in the DOM document tree
has properties and methods defined by the Node host object
![Page 39: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/39.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
![Page 40: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/40.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
(still doesn’t work with IE8, apparently. Chrome OK)
![Page 41: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/41.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
![Page 42: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/42.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: NodeExample HTML document
Function we will write that willuse Node methods and propertiesto produce string representingElement tree
![Page 43: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/43.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
String produced by TreeOutline():
![Page 44: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/44.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Example: “walking” the tree of an HTML document
Reference to html element is contained in documentElement property of document object
Use Node-defined methods to recursively create an outline of nodeName’s:
Depth in tree
![Page 45: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/45.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
![Page 46: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/46.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Contains nodeType value representing Element
![Page 47: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/47.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Ignore non-Element’s
![Page 48: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/48.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Add nodeName to string
![Page 49: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/49.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Recurse onchild nodes
![Page 50: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/50.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
For Element’s, nodeName is type of the element (p, img, etc.)Case: Name will be lower case if browser
recognizes document as XHTML, upper case otherwise
Can guarantee case by using String instance toLowerCase() / toUpperCase() methods
![Page 51: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/51.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Convention: write code as if browser is DOM-compliant, work around non-compliance as needed
In a DOM-compliant browser, we would usethis symbolic constant rather than the constant 1.Problem: IE6 does not define ELEMENT_NODEproperty (or Node object).Solution: Use symbolic constant if available,fall back to numeric constant if necessary.
![Page 52: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/52.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Node
Convention: write code as if browser is DOM-compliant, work around non-compliance as needed
This expression is automatically cast to Boolean.IE6: no Node global, so evaluates to falseDOM-compliant: Node is an Object, so evaluatesto true
![Page 53: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/53.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Initial rendering After user clicks first list item
![Page 54: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/54.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Find theli Elementfollowing theselected one(if it exists)
![Page 55: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/55.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Returns null ifno next sibling
![Page 56: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/56.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Convertingnull to Booleanproduces false
![Page 57: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/57.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Swap nodesif an li elementfollows
![Page 58: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/58.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Operate on a node by calling methodson its parent
![Page 59: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/59.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Modification
Remove following element from tree
Re-insert element earlier in tree
![Page 60: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/60.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: document
The document object is also considered a Node objectTechnically, document is the root Node
of the DOM tree html Element object is a child of document Other children may also include document type
declaration, comments, text elements (white space)
![Page 61: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/61.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: document
![Page 62: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/62.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: document
![Page 63: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/63.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Element Nodes
![Page 64: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/64.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Text Nodes
data property represents character data of a Text node
Modifying the property modifies the corresponding text in the browser
By default, the DOM tree may contain sibling Text nodes
Example: © 2007 might be split into two Text nodes, one with copyright character
Call normalize() method on an ancestor node to prevent this
![Page 65: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/65.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
<body onload="makeCollapsible('collapse1');"> <ol id="collapse1"> <li>First element of ordered list.</li> <li>Second element.</li> <li>Third element.</li> </ol> <p> Paragraph following the list (does not collapse). </p> </body>
Body of original HTML document:
![Page 66: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/66.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
<body onload="makeCollapsible('collapse1');">
<ol id="collapse1"> <li>First element of ordered list.</li> <li>Second element.</li> <li>Third element.</li> </ol> <p> Paragraph following the list (does not collapse). </p> </body> Effect of executing makeCollapsible():
Addedto DOMtree:
![Page 67: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/67.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Added elementis displayed as ifit was part of the HTML sourcedocument
![Page 68: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/68.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
![Page 69: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/69.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Nodecreation
![Page 70: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/70.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Nodeaddition to DOMtree (rec. doingthis immediatelyafter creation).
![Page 71: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/71.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Attributeaddition
![Page 72: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/72.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Before clicking button: After clicking button:
![Page 73: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/73.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
![Page 74: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/74.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Modifying text.
![Page 75: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/75.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Note that the previous example doesn’t work with IE6/7, for at least two reasons:
1. “SetAttribute” doesn’t work, and should be replaced by a direct assignment
2. Even if
button.setAttribute("onclick", "toggleVisibility(this,'" + elementId +"');");
Was replaced with the IE friendly
button.onclick = toggleVisibility;
This seems to have been fixed in IE8
![Page 76: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/76.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: Adding Nodes
Adding Text nodes is often tedious, with the mandatory creation of a new node via “createTextNode” and insertion of the newly created node in the DOM.
A NON STANDARD alternative is to use innerHtml, which lets you just write blocks of html. It is faster (to write and to run), but error prone, and non standard so future support is unknown
![Page 77: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/77.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Document Tree: HTML Properties
Attribute values can be set two ways:
As with CSS properties, former has some advantages:
Makes clear that setting an HTML attribute, not merely a property of an object
Avoids certain special cases, e.g.element.setAttribute(“class”, “warning”); //DOMelement.className = “warning”; //req’d in IE6
class is reserved word in JavaScript
![Page 78: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/78.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
Note: IE6/7 has a different event modelEvent instance created for each eventEvent instance properties: type: name of event (click, mouseover, etc.) target: Node corresponding to document
element that generated the event (e.g., button element for click, img for mouseover). This is the event target.
![Page 79: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/79.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
JavaScript event listener: function that is called with Event instance when a certain event occursAn event listener is associated with a target
element by calling addEventListener() on the element (still doesn’t work with IE8, it seems)
![Page 80: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/80.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
![Page 81: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/81.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
Eventtarget
![Page 82: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/82.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
Event type
![Page 83: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/83.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
DOM event types: All HTML intrinsic events except keypress,
keydown, keyup, and dblclick Also has some others that are typically targeted
at the window object:
![Page 84: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/84.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
Event handler
Definitionof eventhandler
![Page 85: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/85.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
Event instance
![Page 86: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/86.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
Normally false(more later)
![Page 87: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/87.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling
![Page 88: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/88.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
DOM2 mouse events click mousedown mouseup mousemove mouseover mouseoutEvent instances have additional properties for
mouse events
![Page 89: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/89.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
![Page 90: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/90.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
Example: mouse “trail”
![Page 91: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/91.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
HTML document:
JavaScript init() function:
Create“blips”
Add eventlistener
String uniquelyidentifying this div
![Page 92: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/92.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
Style sheet for “blips”:
Initially, not displayed
![Page 93: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/93.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
Event handler updateDivs():
Convert mouse locationfrom Number to Stringand append units
![Page 94: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/94.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Handling: Mouse Events
Event handler updateDivs():
Mod (remainder) operatorused to cycle through “blip” divs(least-recently changed is thenext div moved)
![Page 95: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/95.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Target of event is lowest-level element associated with event
Ex: target is the a element if the link is clicked:
<td><a href=…>click</a></td>However, event listeners associated with
ancestors of the target may also be called
![Page 96: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/96.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Three types of event listeners:
![Page 97: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/97.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Three types of event listeners:
Capturing: Listener on ancestor created with true as third arg.
![Page 98: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/98.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Three types of event listeners:
Target: Listener on target element
![Page 99: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/99.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Three types of event listeners:
Bubbling: Listener on ancestor created with false as third arg.
![Page 100: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/100.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Priority of event handlers:
body ol li a
1. Capturing eventhandlers; ancestorsclosest to roothave highest priority
Target
![Page 101: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/101.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Priority of event handlers:
body ol li a
2. Target event handlers
![Page 102: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/102.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Priority of event handlers:
body ol li a
3. Bubbling eventhandlers; ancestorsclosest to target havepriority.
![Page 103: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/103.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Certain events do not bubble, e.g., load unload focus blur
![Page 104: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/104.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Propagation-related properties of Event instances:
eventPhase: represents event processing phase:1: capturing2: target3: bubbling
currentTarget: object (ancestor or target) associated with this event handler
![Page 105: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/105.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Propagation
Propagation-related method of Event instances: stopPropagation(): lower priority event
handlers will not be called
Typical design: Use bubbling event handlers to provide default
processing (may be stopped) Use capturing event handlers to provide required
processing (e.g., cursor trail)
![Page 106: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/106.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
When cursormoves overupper menu…
![Page 107: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/107.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
…a drop-downappears
![Page 108: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/108.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Background color changes as cursor moves over drop-down items
![Page 109: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/109.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Drop-downdisappearswhen cursorleaves bothdrop-downand menu
![Page 110: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/110.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Document structure:
![Page 111: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/111.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Document structure: Event handlers will be added byJavaScript code
![Page 112: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/112.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Document structure:
Top menuis a table
![Page 113: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/113.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Document structure:
Each topmenu item isa (positioned)div
CSS:
![Page 114: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/114.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Document structure:
Associateddrop-down isin a divthat isout of the normalflow and initiallyinvisible
CSS:
![Page 115: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/115.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Document structure:
Associateddrop-down isa table
![Page 116: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/116.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Full style rules:
![Page 117: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/117.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Full style rules:Top menu item divis “positioned” butnot moved from normalflow location
![Page 118: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/118.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Full style rules:
Upper left corner ofdrop-down div overlapsbottom border of topmenu
![Page 119: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/119.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Full style rules:
Drop-down drawn overlower z-index elements
![Page 120: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/120.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Adding event handlers to top menu: Document:
JavaScript addEventHandlers():
Targeteventhandlers
![Page 121: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/121.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Adding event handlers to top menu: Document:
JavaScript addEventListener():
menuBar1 will be target of events; adding reference to the drop-downdiv makes it easy for event handler to access the drop-down
![Page 122: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/122.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
![Page 123: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/123.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Basicprocessing:changevisibility ofdrop-down
![Page 124: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/124.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Ignorebubblingmouseoverevents fromdrop-down
![Page 125: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/125.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Ignoremouseoutevent ifcursor isremainingover menuitem ordrop-down(self ordescendant)
![Page 126: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/126.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
![Page 127: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/127.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Adding event handlers to drop-down: Document:
JavaScript addEventListener():
![Page 128: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/128.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
![Page 129: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/129.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down MenusDon’tbotherchangingstyle ifthis eventbubbledfrom adescendant.
![Page 130: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/130.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Don’t bubble up to showDropDown sincethe drop-down must be visible
![Page 131: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/131.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Example: Drop-down Menus
Ignoremouseout toa descendant
![Page 132: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/132.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Cancellation
Browser provides default event listener for certain elements and events
Ex: click on hyperlink Ex: click on submit buttonDefault listeners are called after all user-specified
listenersstopPropagation() does not affect default
listenersInstead, call preventDefault() on Event
instance to cancel default event handling
![Page 133: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/133.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
![Page 134: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/134.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
<body onload="addListeners();"> <form id="validatedForm" action="http://www.example.com"> <p> <label>Required input: <input type="text" name="requiredField" id="requiredField" /> </label> <input type="submit" name="submit" value="Click to submit" /> </p> </form></body>
![Page 135: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/135.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
![Page 136: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/136.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
Listen for form to be submitted
![Page 137: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/137.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
Must use value property to accessvalue entered in text field on form
![Page 138: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/138.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
Regular expression literal representing“set of strings consisting only of white space”
![Page 139: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/139.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Form Validation
Cancel browser’s default submit event processing
![Page 140: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/140.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
DOM Event Generation
Several Element’s provide methods for generating events
Ex: causes text in text field to be selected and a select event to occur
![Page 141: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/141.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Detecting Host Objects
How can a JavaScript program test for the existence of a certain host object?
Does the style element have a setProperty() method?
If we’re also not sure that element is defined or that style exists:
![Page 142: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/142.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Detecting Host Objects
Is a browser DOM-compliant? Ex: document.implementation(“Core”, “2.0”) returns true if browser implements all of DOM 2 Core module, false otherwise
Problem: what does false tell you?Many scripts attempt to directly determine the
browser, but… What about new browsers? Some browsers can “lie” about what they are
![Page 143: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/143.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
No Node object (and associated constants)No setProperty() or getPropertyValue()Must use “className” rather than “class” in setAttribute() and getAttribute()Empty div/span height cannot be made
less than character height
![Page 144: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/144.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
No addEventListener() (so no multiple listeners)Cannot use setAttribute() to specify
intrinsic event attribute DOM:
IE6:Value assigned is a function Object (method) rather than a String.
![Page 145: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/145.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Adding listeners to both IE6 and DOM:String-valued in DOM, initially null in IE6
![Page 146: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/146.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Passing arguments to event listeners: DOM:
IE6:Listener is called as a methodin IE6, so this is a referenceto button
![Page 147: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/147.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Passing arguments to event listeners:
DOMapproach
Test that arguments are defined
![Page 148: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/148.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Passing arguments to event listeners:
IE6approach
Test for host object created by IE6 when event occurs
Update: window.event test succeed with Chrome!
![Page 149: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/149.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Passing arguments to event listeners:
IE6approach
DOMapproach
![Page 150: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/150.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Passing arguments to event listeners:
IE6approach
DOMapproach
![Page 151: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/151.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
IE6 does not pass an Event instance to event listenersInstead, IE6 creates a global object event
when an (intrinsic) event occursTesting for non-DOM call: In a DOM-compliant
call to event listenerthere is oneargument that isan Event instance
Basically an Arrayof call arguments
![Page 152: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/152.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:Undefined if IE6
Global object created by IE6
In IE6, evaluates to Objectvalue of DOM’s EventcurrentTarget property
![Page 153: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/153.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
![Page 154: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/154.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
Useexceptionhandlingfor conveniencerather thantestingfor existenceof properties
![Page 155: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/155.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
Most typevalues(exceptdblclick)are copiedwithoutchange
![Page 156: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/156.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
IE6 usesa differentname fortarget
![Page 157: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/157.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
currentTarget passed in from event listener:within eventConvert(), this refers to the global object!
![Page 158: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/158.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
![Page 159: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/159.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:Use function expressions to define DOM methods as setting IE properties
![Page 160: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/160.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
Most mouse-eventproperties are identical
![Page 161: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/161.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:Buttons are numbereddifferently
![Page 162: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/162.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like:
Different names forrelatedTarget
![Page 163: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/163.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
IE6 and the DOM
Converting event object to Event-like: Capturing listeners behave somewhat differently
in IE6 and DOM, so eventConvert() did not attempt to simulate the eventPhase DOM property
![Page 164: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/164.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
Browsers also provide many non-DOM host objects as properties of windowWhile no formal standard defines these
objects, many host objects are very similar in IE6 and Mozilla
![Page 165: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/165.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 166: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/166.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 167: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/167.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 168: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/168.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
open() creates a pop-up window Each window has its own global object, host
objects, etc. Use pop-ups with care:
Pop-ups may be blocked by the browserThey can annoy and/or confuse users
![Page 169: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/169.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 170: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/170.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 171: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/171.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 172: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/172.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 173: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/173.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 174: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/174.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 175: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/175.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 176: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/176.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 177: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/177.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
![Page 178: Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649e725503460f94b70c1a/html5/thumbnails/178.jpg)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey C. Jackson’s slides
Other Common Host Objects
navigator: (unreliable) information about browser, including String-valued properties:
appName appVersion userAgent
screen: information about physical device, including Number properties:
availHeight, availWidth: effective screen size (pixels) colorDepth: bits per pixel