Communicating with web page

Hi,
Does someone have a running example of communication with an Iframe ?
https://developer.playcanvas.com/en/user-manual/publishing/web/communicating-webpage/
I would love to take a look at it, cause i can’t get it to work.

Thanks in advance.
Best Dennis

hi Dennis, i guess this is because of account limitations, with free account i tried it & had

Refused to display ‘https://launch.playcanvas.com/641048?debug=true’ in a frame because it set ‘X-Frame-Options’ to ‘deny’.

in the console. ( codepen test , & open console ), i just cant get the playcanvas in an iframe.

the manual page goes for people with upgrade account i guess too

1 Like

I got this working with a few caveats:

Codepen: https://codepen.io/anon/pen/oPGQbp (click button in the top left of the page)
PlayCanvas project: https://playcanvas.com/project/575319/overview/communicate-with-iframe

  1. You have to use a published build (e.g https://playcanv.as/p/YhVutmbe/)
  2. You have to use the non iframe version of the published build (e.g https://playcanv.as/e/p/YhVutmbe/) Notice the extra e in the URL.

The reason for this is that the normal published build link is wrapped in an iframe of its own so you end up with an iframe in iframe issue and therefore can’t post a message in the right window instance due to it crossing domains from CodePen to PlayCanvas.

The extra e gives you un frame app so it can be embedded directly into a webpage and post messages without crossing domains.

2 Likes

Hi Yaustar,
I was making it way to complex.
Thanks for your straigth on answer. you solved it.
Many many thanks

Hi Borbor,
It actualy works with a published project.
Please take a look at Yaustar anwer.
Anyhow, thanks for the help. You guys are awesome.

Edit:
I connected the app with Ninjaforms in wordpress.
Works very good.
https://kubuz.net/home/configurator-playground/

1 Like