Tham khảo sách 'javascript bible_ chapter 16', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | The Document Object User interaction is a vital aspect of client-side JavaScript scripting and most of the communication between script and user takes place by way of the document object and its components. Understanding the scope of the document object is key to knowing how far you can take JavaScript. Review the document object s place within the JavaScript object hierarchy. Figure 16-1 clearly shows that the document object is a pivotal point for a large percentage of JavaScript objects. In fact the document object and all that it contains is so big that I have divided its discussion into many chapters each focusing on related object groups. This chapter looks only at the document object while each of the eight succeeding chapters details objects contained by the document object. I must stress at the outset that many newcomers to JavaScript have the expectation that they can on the fly modify sections of a loaded page s content with ease replace some text here change a table cell there. It s very important however to understand that except for a limited number of JavaScript objects Netscape s document object model does not allow a lot of content manipulation after a page has loaded. The items that can be modified on the fly include text object values textarea object values images starting with Navigator 3 and select object list contents In This Chapter Accessing arrays of objects contained by the document object Changing content colors Writing new document content to a window or frame 298 Part III JavaScript Object and Language Reference Figure 16-1 The JavaScript object hierarchy A handful of other invisible properties are modifiable after the fact but their settings don t survive soft reloads of a document. If your pages need to modify their contents based on user input or timed updates consider designing your pages so that scripts write the contents then let the scripts rewrite the entire page with your new settings. Dynamic HTML and Documents Navigator 4 and