Skip to main content
JEJoll
Known Participant
September 14, 2016
Answered

Setting a Button's onclick event to an undefined/custom function

  • September 14, 2016
  • 1 reply
  • 861 views

I'm not a captivate developer, but I'm developing a page that will be embedded as an iframe (webobject) inside of a captivate page. The page that I'm developing will display a graph, the data for which will depend on which button is clicked in the parent Captivate page.

Ideally, I'd like to be able to have my captivate developer simply set each button's onclick event to call some function (by name) that I'll define in my iframe page. To do this, I was hoping there was an option to simply give the function name to an onclick event in captivate, so that my iframe can 'reach' into the parent, and set that function equal to a function I've defined in my graph page.

Essentially, I want the end result to be (in a nutshell) something like this:

Captivate page:

<someButton onclick="CaptivateTest1">

<someButton2 onclick="CaptivateTest2">

<iframe src="myGraph.html></iframe>

myGraph.html:

<html>

<!--...Graph stuff here-->

<script>

function myDefinedFunction(){

//Change graph data

}

function myOtherDefinedFunction(){

//Change graph data

}

window.parent.CaptivateTest1 = myDefinedFunction;

window.parent.CaptivateTest2 = myOtherDefinedFunction;

</script>

</html>

This topic has been closed for replies.
Correct answer TLCMediaDesign

Define your functions in the html document in the iFrame:

window.parent.CaptivateTest1 = function()

{

     //do some stuff

}

Then have you developer execute JavaScript in the JS Window attached to the button:

CaptivateTest1();

1 reply

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
September 14, 2016

Define your functions in the html document in the iFrame:

window.parent.CaptivateTest1 = function()

{

     //do some stuff

}

Then have you developer execute JavaScript in the JS Window attached to the button:

CaptivateTest1();

JEJoll
JEJollAuthor
Known Participant
September 14, 2016

The simple answers are usually the right ones. It looks like this should work (why didn't I think of this?). I'll let you know once I've had a chance to test. Thanks for this.