The
documentRoot
attribute specifies the
local directory from which to load URLs that resolve to files within
the location specified by
sandboxRoot
.
When
resolving URLs, either in the frame
src
attribute,
or in content loaded into the frame, the part of the URL matching
the value specified in
sandboxRoot
is replaced
with the value specified in
documentRoot
. Thus,
in the following frame tag:
<iframe src="http://www.example.com/air/child.html"
documentRoot="app:/sandbox/"
sandboxRoot="http://www.example.com/air/"/>
child.html
is
loaded from the
sandbox
subdirectory of the application installation
folder. Relative URLs in
child.html
are resolved
based on
sandbox
directory. Note that any files
on the remote server at
www.example.com/air
are
not accessible in the frame, since AIR would attempt to load them
from the app:/sandbox/ directory.
Specifies an event handler for the
dominitialize
event
of a frame. This event is an AIR-specific event that fires when
the window and document objects of the frame have been created,
but before any scripts have been parsed or document elements created.
The
frame dispatches the
dominitialize
event early
enough in the loading sequence that any script in the child page
can reference objects, variables, and functions added to the child
document by the
dominitialize
handler. The parent
page must be in the same sandbox as the child to directly add or
access any objects in a child document. However, a parent in the
application sandbox can establish a sandbox bridge to communicate
with content in a non-application sandbox.
The following
examples illustrate use of the iframe tag in AIR:
Place
child.html
in
a remote sandbox, without mapping to an actual domain on a remote
server:
<iframe src="http://localhost/air/child.html"
documentRoot="app:/sandbox/"
sandboxRoot="http://localhost/air/"/>
Place
child.html
in
a remote sandbox, allowing XMLHttpRequests only to
www.example.com
:
<iframe src="http://www.example.com/air/child.html"
documentRoot="app:/sandbox/"
sandboxRoot="http://www.example.com/air/"/>
Place
child.html
in
a remote sandbox, allowing XMLHttpRequests to any remote domain:
<iframe src="http://www.example.com/air/child.html"
documentRoot="app:/sandbox/"
sandboxRoot="http://www.example.com/air/"
allowCrossDomainXHR="allowCrossDomainXHR"/>
Place
child.html
in
a local-with-file-system sandbox:
<iframe src="file:///templates/child.html"
documentRoot="app:/sandbox/"
sandboxRoot="app-storage:/templates/"/>
Place
child.html
in
a remote sandbox, using the
dominitialize
event
to establish a sandbox bridge:
<html>
<head>
<script>
var bridgeInterface = {};
bridgeInterface.testProperty = "Bridge engaged";
function engageBridge(){
document.getElementById("sandbox").parentSandboxBridge = bridgeInterface;
}
</script>
</head>
<body>
<iframe id="sandbox"
src="http://www.example.com/air/child.html"
documentRoot="app:/"
sandboxRoot="http://www.example.com/air/"
ondominitialize="engageBridge()"/>
</body>
</html>
The following
child.html
document
illustrates how child content can access the parent sandbox bridge:
<html>
<head>
<script>
document.write(window.parentSandboxBridge.testProperty);
</script>
</head>
<body></body>
</html>
For more information, see
Cross-scripting content in different security sandboxes
and
HTML security in Adobe AIR
.