Sending variable to parent window from iframe

Hiya

I have an iframe created with hype within a parent html.
In the parent I have instantiated the variable 'rating'

Within the iframe on scene load I have created the script below:

parent.ratingIframe = window;
window.rating = 0;

This does not alter the parents variable 'rating'....

Can anybody tell me what I have done wrong?

Thanks

is the safest bet.

Whoa that was quick....thanks MaxZieb,

Not sure how I would intercept the postmessage() and update the variable, could I use a query manager as I would a normal post request?

Have a look at https://gist.github.com/cirocosta/9f730967347faf9efb0b


As an alternative, you can also use Hype GlobalBehavior and Hype CommandPipeline although that might not be necessary for just a simple variable.

haha just looked at that link seconds before your reply....the only problem is that it is sending the message to the iframe rather than the other way round.

In your expert opinon what would be the quickest way of achieving what I need.

Could you possibly just rough out a bit of pseudo code to give me a starting point?

Thanks again :slight_smile:

postMessage.hype.zip (17,6 KB)

1 Like

Max

You're a genius! Now makes total sense... thankyou so much for your time :slight_smile:

3 Likes