Communication from AMP parent frame to page in iframe
Asked Answered
N

1

7

I am building a static website using Accelerated Mobile Pages (AMP). Many pages contain iframes using the "amp-iframe" tag. The child pages are not AMP-compliant.

I need a way for a child page to determine when the parent page has finished loading. The normal parent.window.onload can't be used here because the parent pages will often be in different domains (mostly Google's caches) than the child pages.

AMP implements some portion of the postMessage method as a way to communicate between frames (https://www.ampproject.org/docs/reference/components/amp-iframe), but it is poorly documented and I can't figure out how to reliably pass messages beyond the one example shown at that page.

Any help would be greatly appreciated.

Neither answered 11/1, 2017 at 22:10 Comment(0)
G
0

Try downloading some of their free website templates. I think some have forms and a result page which might use iframe.

Example of dynamic interaction with iframe: https://amp.dev/documentation/examples/components/amp-iframe/

I agree their documentation is lousy. Would be so easy if they just posted more example sites and templates.

Gesundheit answered 16/9, 2020 at 19:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.