Saturday, October 15, 2016

DOM 101.

Node Types
  1. Element_node
  2. Attribute_node
  3. Text_node
  4. Cdata_section_node
  5. Entity_reference_node
  6. Entity_node
  7. Processing_Instruction_node
  8. Comment_node
  9. Document_node
  10. Document_type_node
  11. Document_fragment_node
  12. Notation_node

Node Relationships

  • childNodes - a NodeList ordered by  position / index.
    • firstChild
    • lastChild
    • nth-child
  • parentNode
  • nextSibling or previousSibling
  • Ancestors or Descendants

Window Objects and Its Children (DOM as a tree)

  • Window
    • Self
    • Document
      • html
        • head
          • title
        • body
          • p -> innerText
          • p -> LinkText -> a -> www/URL
    • Navigator
    • Screen
    • Forms
    • History
    • Location

Window Object Methods and Properties
  • Methods
    • addEventListener()
    • attachEvent()
    • blur()
    • focus()
    • close()
    • detachEvent()
    • removeEventListener()
    • open()
    • print()
    • Moving and Resizing
      • moveBy()
      • moveTo()
      • resizeBy()
      • resizeTo()
    • Timers
      • clearInterval()
      • clearTimeout()
      • setInterval()
      • setTmeout()
    • Get Information of the Screen
      • availHeight
      • availWidth
      • colorDepth
      • height
      • width
  • Properties
    • closed
    • defaultStatus
    • name
    • opener
    • parent
    • status
    • top

Example
alert ("Available Height: " + screen.availHeight);
alert ("Total Height: " + screen.height);
alert ("Available Width: " + screen.availWidth);
alert ("Total Width: " + screen.width);

// navigator object
var body = document.getElementsByTagName ("body")[0];
for (var prop in navigator) {
   var elem = document.createElement("p");
   var text = document.createTextNode (prop + ": " + navigator[prop]);
   elem.appendChild(text);
   body.appendChild(elem);
}




No comments:

Post a Comment