# Creation of DFrames : Behavior

## Principles

The code of the instantiation of a DFrame has been seen previously:

var dFrame = new DFrame(position, title, dFrameStyle)

This code instanciate a DFrame that, on creation, will be added to the window of the browser.

It is however possible - and it is the most frequent case - to add a DFrame to another DFrame: Most of times DFrames of an application are added to a basic DFrame:

var baseAll = new DFrame(position, title, dFrameStyle);

var dFrame = new DFrame(position, title, dFrameStyle, baseAll)

This code creates DFrame dFrame on DFrame baseAll. This will have several consequences:

## Position

- The 4 values of position (left right corner positions, right bottom corner positions) are related to the parent of the DFrame.
- The bars (as well as the borders and the title bar) of the parent DFrame will be preserved and not covered by the new DFrame.

Example

## file: newDFrame.html

Run the example
See the source code

Some methods detailed in the reference document allow covering the bars of the parent DFrame or juxtaposing two DFrames in a precise way.

## Implicit creations

In the preceding case DFrame dFrame can be created only if DFrame baseAll has been created. The creation of dFrame involves the implicit creation of baseAll.

If the code had ended with

baseAll.show()

the DFrame baseAll would have been visible but not the DFrame dFrame.

## Closing

If a DFrame is closed all DFrames which it contains will be it too. Try the close button of the example (right top corner): It closes baseAll and also dFrame.