SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Dynamic Content Techniques : Conclusion

You have now seen two approaches to building interactive dynamic content. Which approach you choose depends upon what you are trying to achieve. If Internet Explorer 4.0 compatibility is a must, then the first approach is your own solution. If this is not a requirement, consider using the second approach whenever you need to manipulate the individual HTML elements of the new content. You will find the object-oriented approach to constructing HTML much more direct and reliable compared to trying to manipulate the HTML after it has been inserted.

This article provides you a glimpse into the new HTML manipulation methods available in Internet Explorer. Beyond creating HTML objects Internet Explorer 5.0 also lets you create text node objects. These are objects that contain nothing but content that can be inserted into your HTML fragment. Looking at our object-approach for creating the table of contents, we still chose to use the innerText property to set the contents of each table of content entry. By using text-node objects we could have created a text object with the text for each table of content entry and then inserted it into the LI element. We chose not to take this approach as our needs to not require that additional flexibility.

Also, the new methods for building HTML documents node by node are from the new W3C Document Object Model recommendation. While the createElement and element insertion methods are part of the standard the innerText property is a Microsoft specific property. For this article we explicitly chose to focus on providing solutions that fit our specific task at hand and will cover the standards-based programming model in the future. The W3C recommendation is defined to provide generic tree manipulations and as such would have taken more code to solve the same task. The two primary differences are how we traversed the document and how we set the text of the LI node. For the document traversal, we would need to traverse the HTML document tree manually rather than walk the flattened all collection, and we would need to use text-nodes for setting any text. Also, even if we programmed to the DOM recommendation, the recommendation still does not contain an event model making it impossible to make a standard-compliant live table of contents.

Next, Internet Explorer 4.0 and 5.0 users can view a demonstration of our table of contents. The next page combines the entire article into a single document. The table of contents is generated using the string-based approach and inserted at the top of the page (after the page is loaded).