ActivePresenter Saola Animate Pricing Download

Access object in iframe with javascript

(Jean-Michel) #1


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


(Toan Le) #2


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.