Access object in iframe with javascript

Problem:

I insert an iframe in a slide and I want to exchange variables between the slide and an object in the iframe. How can I do ?
For example if I click on a button in the iframe I wish that it modifies a variable of the slide and vice versa.

ActivePresenter Version: 7.5.6

OS: windows seven

Notes:

1 Like

Hi,

You can use prez.object('Web Object name').frameNode to get iframe element inside a Web Object element. After that, please use contentWindow and/or contentDocument property of this iframe to make change to the iframe content. For example:

var iframeDoc = prez.object('Web Object_4').frameNode.contentDocument;
var divInIframe = iframeDoc.getElementById('div-1');
divInIframe.innerHTML = 'New Text';

To get ActivePresenter presentation from an iframe, you can use parent.AtomiAP.presentations[0]. For example:

var parentPrez = parent.AtomiAP.presentations[0];
parentPrez.variable('ShapeText', 'New Shape Text');

web object.approj (384 KB)

Please note that if two frames are cross-origin, you must use post​Message for communication.

Regards

Hello,
The problem is solved.
using prez.showSidebar (! prez.sidebarVisible ());
I had problems because I set sidebar : none in the viewer.
So I put the sidebar on the left, I hide it from the beginning of the reading and I insert a button that makes it appear when I want it.