# Use DynAPI in a page loaded in a DFrame

## Access DynAPI

DynAPI objects can be created in 2 manners:

· DynAPI.document.addChild(DynAPIObject): The DynAPI object is added to DynAPI.document

· DynAPIObject.addChild(DynAPIObject): The DynAPI object is added to another DynAPI object.

On a document loaded in a DFrame the createDynAPIDocument method creates an object which which will be

· a DynAPI.document object for IE / NS6

· a DynAPI object for NS4.

It will be then possible to add a DynAPI object to this object.

Remark: The createDynAPIDocument needs the DFrame to be created with the setURL or the alert methods and does not work if the DFRame is created with the show method.

Example 1:

A DynAPI object is created and added to DynDoc by the code stored is a page loaded in a DFrame:

<script language="Javascript">

function onLoadDFrame(){

myLayer = new mainPage.DynLayer()

DynDoc = thisDFrame.createDynAPIDocument()

DynDoc.addChild(myLayer)

}

</script>

Remark: As DynAPI libraries are stored in mainPage the DynLayer object ('myLayer') must be called thru the 'mainPage' variable.

Example 2:

A DynAPI object is created by the onEvent function of a DFrame:

…

dFrame.setURL(url)

dFrame.onEvent = function(e) {

if (e.action == 'postCreate' && e.dFrame == dFrame) {

myLayer = new DynLayer()

DynDoc = this.createDynAPIDocument()

DynDoc.addChild(myLayer)

}

}

Remark:

· As DynAPI libraries are stored in in the same page as the code the DynLayer object can be called directly.

Demo

All examples of the next page use the DynDoc variable.

See also

file: advanced.XML.html

Run the example

See the source code

## URL

We met a very special problem with URL inside examples: We have been obliged to add one "../" more for all URL used by NS6.

Example: gui.buttonimage.html:

if (is.ns6) {

var normal = mainPage.DynImage.getImage("../../../../dynapi/src/lib/dynapi/images/common/button.gif", true);

} else {

var normal = mainPage.DynImage.getImage("../../../dynapi/src/lib/dynapi/images/common/button.gif", true);

}

It seems that in the syntax

var normal = mainPage.DynImage.getImage("../../../../dynapi/src/lib/dynapi/images/common/button.gif", true);

the starting point for the URl is

· The page containing the code of the DynImage object for IE, ie mainPage.

· The page from where the DynImage object is called for NS6: This page in contained is a sub directory of the one containing mainPage.

Concerned examples are

· gui.button.html

· gui.buttonimage.html

· gui.dynimage

· util.imganim.html.

· gui.loadpanel.html

This problem also obliged us to create a special release of scrollbar.js called scrollbarForDFrame.js where the setImages method has been modifed.

Developpers who should intensively use DynAPI in dFrameAPI should better correct the following functions of DynAPI:

DynImage.getImage=function(src,w,h) {

LoadQueue.prototype.loadNext=function() {

DynLayer.prototype.setBgImage=function(path)