Search code examples
iframeamp-html

Friendly iframe with AMP


Is it possible to create a friendly iframe with AMP?

I was looking at amp-iframe tag, but it requires src, which makes it to belong to another domain, thus restricting access to a parent document due to cross domain policy.

Is there a way to create a friendly iframe, which won't have such restriction?

UPDATE: I'm trying to embed a widget into an AMP page which will display additional interactive content based on the page keywords as well as an ad. On a 'traditional' web page this can be done though friendly iframes. I wonder if there is some workaround for AMP?


Solution

  • It's not possible to create friendly iframes, the reason is that AMP pages might be served via an AMP Cache on a different origin. In that case friendly iframes would no longer work.

    You can embed iframes from the same origin via amp-iframe if you omit the allow-same-origin attribute. There's also a new two-way-messaging between amp-iframes and the AMP doc being implemented. This should be available soon.