Summary

You learned quite a bit in this chapter. You learned the following cross-browser BOM objects:

  • Properties of the global window object, such as navigator, location, history, frames, screen
  • Methods such as setInterval() and setTimeout(); alert(), confirm() and prompt(); moveTo/By() and resizeTo/By()

Then, you learned about the DOM, an API to represent an HTML or XML document as a tree structure, where each tag or text is a node on the tree. You also learned how to perform the following actions:

  • Accessing nodes:
    • Using parent/child relationship properties, such as parentNode, childNodes, firstChild, lastChild, nextSibling, and previousSibling
    • Using getElementsById(), getElementsByTagName(), getElementsByName(), and querySelectorAll()

  • Modifying nodes:
    • Using innerHTML or innerText/textContent
    • Using nodeValue or setAttribute(), or just using attributes as object properties

  • Removing nodes with removeChild() or replaceChild()
  • Adding new ones with appendChild(), cloneNode(), and insertBefore()

You also learned the following DOM 0 (pre-standardization) properties, ported to DOM Level 1:

  • Collections, such as document.forms, images, links, anchors, applets. Using these are discouraged as DOM1 has the much more flexible getElementsByTagName() method.
  • The document.body element, which gives you convenient access to <body>.
  • The document.title, cookie, referrer, and domain.

Next, you learned how the browser broadcasts events that you can listen to. It's not straightforward to do this in a cross-browser manner, but it's possible. Events bubble up, so you can use event delegation to listen to events more globally. You can also stop the propagation of events and interfere with the default browser behavior.

Finally, you learned about the XMLHttpRequest object that allows you to build responsive web pages that do the following tasks:

  • Make HTTP requests to the server to get pieces of data
  • Process the response to update portions of the page
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.238.76