getParentDFrame.html

<HTML>

<HEAD>

<script>var dFrameFilePath = '../../../'</script>

<script language="Javascript" src="../../../lib/dFrameAPI.js"></script>

<script language="Javascript">

//Style

DFrameAPI.include('styles/blue/styleBlue.js')

//globals

var baseAll, insertedDFrame

DFrameAPI.onLoad = function(){

baseAll = new DFrame([0, 0, 100, 100], 'baseAll', dFrameStyle)

baseAll.addButton('Test getParentDFrame()', 'testGetParentDFrame(thisDFrame)');

baseAll.addButton('Insert getParentDFrame.html', 'insertPage("./getParentDFrame.html")');

baseAll.onEvent = function(e) {

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

var p = e.dFrame.getParentDFrame()

if (p == null) e.dFrame.setTitle('FIRST container')

else e.dFrame.setTitle('SUB of ' + p.title)

e.cancelBubble = true

}

}

baseAll.show()

}

function insertPage(url) {

if (!insertedDFrame) {

insertedDFrame = new DFrame([2, 2, 98, 98], 'Inserted DFrame', dFrameStyle, baseAll);

insertedDFrame.addButton('Test getParentDFrame()', 'testGetParentDFrame(thisDFrame)');

insertedDFrame.onEvent = function(e) {

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

var p = e.dFrame.getParentDFrame()

if (p == null) alert('Never happend: insertedDFrame has always a parent')

else e.dFrame.setTitle('SUB of ' + p.title)

e.cancelBubble = true

}

}

}

insertedDFrame.setURL(url)

}

function testGetParentDFrame(dFrame) {

var t = dFrame.getParentDFrame() == null ? 'No parent' : dFrame.getParentDFrame().title

alert('Parent for ' + dFrame.title + ': ' + t)

}

</script>

</HEAD>

</HTML>