# Code in mainPage: Access DFrame

Goal: To reach DFrames to use their methods or properties.

Common case: Use DFrame's names of instantiation.

The reference to a DFrame is done in a normal way by the name that was used for it at the time of its instantiation:

//Instanciation

dFrame = new DFrame(pos, title, dFrameStyle);
//Access to a method

dFrame.show();

Particular case 1: Actions of Buttons can use the 'thisDFrame' keyword

The code defining the action of a Button runs in mainPage. It is defined by a string that will be evaluated as JavaScript Code.

It can thus, as usual, reference DFrames by their names:

//create in a dFrame a button that will change the page inserted in it
dFrame.addButton('New page', 'dFrame.setURL("newPage.html")')

However it is possible to refer the DFrame that contains the button by the keyword 'thisDFrame', which produces a reusable code:

dFrame.addButton('New page', 'thisDFrame.setURL("newPage.html")')

This possibility prohibits the use of the name 'thisDFrame' for a DFrame.

The 'thisDFrame' keyword is also authorized as parameter for a function or method:

dFrame.addButton('Tell url', 'alert(thisDFrame.getURL())')

Particular case 2: Actions of Buttons can use the 'topDFrame' keyword

The 'topDFrame' always point to the DFrame on top of the screen. It allows having, for instance, a Tool bar that will be common for many DFrames.

Example

file: topDFrame.html

Run the example

See the source code