Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Sep 14, 2016 Sep 14, 2016

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>

705
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 14, 2016 Sep 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();

Translate
People's Champ ,
Sep 14, 2016 Sep 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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 14, 2016 Sep 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 15, 2016 Sep 15, 2016

This worked like a gem. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 15, 2016 Sep 15, 2016
LATEST

You're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources