CHAPTER 3 CONTENT CHUNKING PATTERN the innerHTML (Web hosting india)
Sunday, January 27th, 2008CHAPTER 3 CONTENT CHUNKING PATTERN the innerHTML property. However, things can run amok if the innerHTML property is manipulated when it should not be manipulated or when doing so will violate the structure of the HTML. For instance, as illustrated in the example you cannot create a table without rows or cells. Another way to interact with the HTML Document Object Model is to use individual elements that are instantiated, manipulated, and deleted. Using the Document Object Model, it is much harder to mess up because this model supports only certain methods and properties. When using the HTML Document Object Model, it is not as simple to arbitrarily remove all the rows and replace them with text. There are no methods on the table object model to create a construct, as illustrated in Figure 3-8. It is important to remember that entire chunks of HTML content are replaced when using the Content Chunking pattern. So even though the property innerHTML is powerful and flexible, replacing the wrong chunk at the wrong time will result in an incorrectly formatted HTML page. What you need to remember is that when referencing HTML elements in the context of the pattern,only framework HTML elements usedto contain content chunks shouldbereferenced. As a pattern rule, script in the HTML framework page should not directly reference injected elements, as that would create a dynamic dependency that may or may not work. If such a dependency is necessary, encapsulate the functionality and call a method on the injected elements. JavaScript allows the assignment of arbitrary functions on HTML elements. Identifying Elements It was previously mentioned that when finding elements by using a tag type, it is not possible E B V N to know the identifier; and when finding elements using the identifier, it is not possible to know the tag type. Regardless of how the elements have been found, they are considered a starting point from which manipulations can happen. Based on the starting point, a script can navigate the parent or the child elements by using a number of standard properties and methods. These standard properties and methods are available on virtually all HTML elements, and script writers should focus on using them when navigating a hierarchy, modifying the look and feel, or attempting to identify what the element is. Table 3-1 outlines properties that are of interest when writing scripts. Table 3-1. HTML Element Properties Useful for Writing Scripts Property Identifier Description attributes[ Contains a read-only collection of the attributes associated with the HTML element. An individual attribute can be retrieved by using the method getAttribute. To assign or overwrite an attribute, the method setAttribute is used. To remove an attribute, the method removeAttribute is used. childNodes[ Is an instance of NodeList that most likely is referenced by using an array notation, but the array is read-only. To add a child node to the current element, the method appendChild is used. To remove a child node, the method removeChild is used; and to replace a child node, replaceChild is used. className Assigns a stylesheet class identifier to an element. A class type is very important in Dynamic HTML in that the look and feel of the element can be dynamically assigned. dir Indicates the direction of the text, either left to right (ltr) or right to left (rtl).
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.