Goal: To reach the
variables and functions of a page inserted in a DFrame.
When a HTML page is inserted in a DFrame it is included in a
'container'.
This container will have a different nature according to the
browser used: A window object for Internet Explorer and Netscape 6 and a layer
for Netscape 4.
The access to the container itself offers only little
interest. The access to the objects of the container, and particularly to the
document object, as well as the variables and functions stored in the
container, is on the other hand essential.
Way: Use 'window'
keyword.
The access to the container is done by the keyword 'window':
var dFrame = new DFrame(parameters)
dFrame.setURL(url)
//call to the function ‘inlineFunction’ stored in the page defined by ‘url’:
dFrame.window.inlineFunction()
Caution: This code, such as,
will not work, the page corresponding to ' url' being likely not completely loaded
when the 'inlineFunction' function is
called. The function onLoadDFrame
allow circumventing this problem.
Example 1 :
In a page inserted in
the DFrame dFrame :
function alertValue() {
alert('this is a message from the page of a dFrame')
}
In mainPage :
dFrame.window.alertValue()
return 'this is a
message from the page of a dFrame'
Example 2 :
If the
page inserted in the DFrame dFrame contains a form, the code in mainPage
for (var i in dFrame.window.document.forms[0])
alert(i)
will
return all the elements of the form.
Example 3
The code
defining the action of a Button uses the keyword 'thisDFrame' to reach the
DFrame containing the Button and then the keyword 'window' to reach a function
or elements of the page:
dFrame.addButton('text',
'thisDFrame.window.inlineFunction()')
or
dFrame.addButton('text',_
thisDFrame.window.document.forms[0].fieldName.value="Value"')