Javascript Post Message to the parent iframe

Hi, firstly can I say I'm not a Hype or javascript expert so any help will be welcome.

I'm using Hype as an html5 animation tool for elearning purposes. The main elearning course is built in Adapt and the Hype interactive animations will sit inside Adapt iframes. The idea is that Hype sends an interaction 'complete' message via postMessage to Adapt. The Adapt iframe is ready built to listen for a postMessage sending 'complete'. So the external iframe is the parent and Hype is the child.

If I put the following in a simple html page window.parent.postMessage('complete', '*'); on my web server and reference the html page within the iframe I can trigger the iframe interaction as complete without any issues.

I have built a test Hype page with a simple button and a javascript function using the same code but when it is all online (Adapt iframe and Hype animation inside) I'm not triggering the complete status.

I'm also running an alert on the button (which works) so I'm fairly sure the javascript postmessage function is running.

Could it be that the external iframe is not found with window.parent from inside Hype and needs something else putting into the javascript function.

regards
Trevor

your nesting of iFrames is unclear. in the end it should be possible ...
may be try to log

document.parentWindow.frames

from within hype and see if you find a corresponding reference that is a regular targetElement for your message

Hi, thanks for the reply, I think this will be a bit of trial and error.

How do I use document.parentWindow.frames?
What/where should I see the result.
I'm guessing if it runs as a function inside hype it will return something on screen showing the frames?
Sorry to ask but I'm a graphics/elearning author not a programming expert.

... which can be inspected from developer tools console ...

providing livelinks would be of some help :slight_smile:

Ok, I understand, many thanks.

I'll try that out next week.

Trevor