onEvent.html

<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')

DFrameAPI.onLoad = function(){

var dFrame = new DFrame([10, 10, 90, 90], 'onEvent.html', dFrameStyle)

dFrame.addButton('Open a dFrame with a document', 'createDFrame("./onEvent/document.html")')

dFrame.addButton('Open a dFrame with a form', 'createDFrame("./onEvent/form.html")')

dFrame.addText([5, 5], 'The onEvent function of the DFrames receiving the pages will set a background color<br>depending on the existance of a form.')

dFrame.show()

}

function createDFrame(url) {

dFrameStyle.setIndentX(40)

dFrameStyle.setIndentY(40)

var dFrame = new DFrame([30, 30, 70, 70], 'Test for onEvent', dFrameStyle, dFrame)

dFrame.onEvent = function (e) {

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

if (dFrame.getURL().indexOf('document.html') != -1) {

alert('onEvent for document:\nGoing to set a blue background for a document\nand update the title.')

dFrame.setContentBgColor('blue')

dFrame.setTitle('document.html')

}

if (dFrame.getURL().indexOf('form.html') != -1) {

alert('onEvent for form:\nGoing to set a red background for a form\nand update the title.')

dFrame.setContentBgColor('red')

dFrame.setTitle('form.html')

}

e.cancelBubble = true

}

}

dFrame.setURL(url)

}

</script>

</HEAD>

</HTML>