Java Reference
In-Depth Information
differences between the dom and the bom
As mentioned earlier, two main differences exist between the document object model and the
browser object model. However, complicating the issue is the fact that a BOM is sometimes referred
to under the name DOM. Look out for this in any literature on the subject.
First, the DOM covers only the document of the web page, whereas the BOM offers scripting
access to all areas of the browsers, from the buttons to the title bar, including some parts of
the page.
Second, the BOM is unique to a particular browser. This makes sense if you think about it:
you can't expect to standardize browsers, because they have to offer competitive features.
Therefore, you need a different set of properties and methods and even objects to be able to
manipulate them with JavaScript.
representing the html document as a tree structure
Because HTML is standardized so that web pages can contain only the standard features supported in
the language, such as forms, tables, images, and the like, a common method of accessing these features
is needed. This is where the DOM comes in. It provides a uniform representation of the HTML
document, and it does this by representing the entire HTML document/web page as a tree structure .
In fact, it is possible to represent any HTML as a tree structure, and for best results, the HTML
document should be well formed. Browsers tolerate, to a greater or lesser extent, quirks such as
unclosed tags, or HTML form controls not being enclosed within a <form/> element; however,
for the structure of the HTML document to be accurately depicted, you need to be able to always
predict the structure of the document. The ability to access elements via the DOM depends on the
ability to represent the page as a hierarchy.
What Is a tree Structure?
If you're not familiar with the concept of trees, don't worry. They're just a diagrammatic means of
representing a hierarchical structure.
Let's consider the example of a book with several chapters. If instructed to, you could find the
third line on page 543 after a little searching. If an updated edition of the topic were printed with
extra chapters, more likely than not you'd fail to find the same text if you followed those same
instructions. However, if the instructions were changed to, say, “Find the chapter on still‐life
painting, the section on using watercolors, and the paragraph on positioning light sources,” you'd
be able to find that even in a reprinted edition with extra pages and chapters, albeit with perhaps a
little more effort than the first request required.
Topics aren't particularly dynamic examples, but given something like a web page, where the
information could be changed daily, or even hourly, can you see why it would be of more use to give
the second set of directions than the first? The same principle applies with the DOM. Navigating the
DOM in a hierarchical fashion, rather than in a strictly linear way, makes much more sense. When
you treat the DOM as a tree, it becomes easy to navigate the page in this fashion. Consider how
you locate files on your computer. The file/folder manager (Windows Explorer in Windows, Finder
in Mac OS, and so on) creates a tree view of folders through which you can drill down. Instead of
looking for a file alphabetically, you locate it by going into a particular folder.
 
Search WWH ::




Custom Search