How to communicate of iframe score data with parent page

Need a little help I want to get a score from the iframe game and show my data on the parent page console. Need code :slight_smile:

Hi @HasnainX,

You can use the standard JS postMessage() API to communicate between the two instances. Check this manual page, it includes a code sample:

https://developer.playcanvas.com/en/user-manual/publishing/web/communicating-webpage/#embedded-in-iframe

1 Like

Is any project live means this code implemented it would be better for me to understand the code?

Ah, sadly I am not aware of a public PlayCanvas project that implements that as an example.

You may be able to find generic Javascript examples though if you do an internet search.

Ok thanks for the information

1 Like

Hey @HasnainX , the following thread may be helpful in implementing the communication using postMessageApi.

3 Likes

Well thanks, @saif Is any project live means this code is implemented it would be better for me to understand the code?

I am afraid there is no public project in my knowledge.