15.4. HTML Document Object Model

The contents of the HTML Document Object Model (DOM) are fully accessible. By accessing the document property of the HTML component's htmlLoader, you will have full access to all of the DOM's properties and methods. This section will demonstrate a few ways to access parts of the DOM. For more information on the properties and methods available, you may reference the WebKit DOM reference at developer.apple.com/documentation/AppleApplications/Reference/WebKitDOMRef/index.html.

To demonstrate a few of the DOM properties and methods, create a new AIR project named Chapter15_DOM, which will create a new file named Chapter15_DOM.mxml. Within this file, please add the contents of Listing 15-7. Listing 15-7 currently has only an HTML component with its location set to www.google.com. The results can be seen in Figure 15-5. We will add to this file in the following sections on accessing the DOM.

Figure 15-4. The HTML component's HTMLHistoryItems.
Example 15-7. The base of the Chapter15_DOM.mxml file
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" width="850" height="700">
    <mx:HTML id="html" location="http://www.google.com" width="800" height="509"
        horizontalCenter="0" y="120"/>
</mx:WindowedApplication>
Figure 15-5. The base of the Chapter15_DOM.mxml file.

15.4.1. innerHTML ...

Get Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.