I’m working on a basic prototype that involves having a PlayCanvas app loaded into an iframe, and all the controls for the app are on the parent page. The parent page and the PlayCanvas app will almost definitely be hosted on separate servers (I have no say in this), so I’ve been looking into postMessage.
I’ve got a feeling I’m missing something simple, but at this point I’ve spent hours on this and I figured it was time to ask for help
For the communication between different windows, postmessage is surely a better solution than anything. I was trying the same thing from the iframe but id didn’t seem to work. So, i changed things by first i sent a message from playcanvas like this so that my window may know that playcanvas build is loaded: window.top.postMessage("Playcanvas_Ready", "*");
And received it on the other window i.e iframe with the following function:
Thanks for the help guys! I think I’ve got it figured out now.
@saif’s example helped me clear up what I was trying to do.
Part of the problem looks like a Chrome extension I was using would spam about a dozen events when the page loaded which was making me think a lot more was actually happening than what should have been.
I need to clean up a couple things then I’ll post the finished code in case someone else stumbles on this thread.