ColorCutClarity
ColorCutClarity

Reputation: 23

amp-iframe JavaScript implementation

I am running into some issues converting an existing page to comply with AMP-html. I am using amp's "iFrame" component so I can bring in a component that is standalone depending on its own JavaScript. The component is fully functional by itself, issue is when it gets iFramed in some of (or most of) the functionality does not work.

Is this going against AMP's guidelines? I can't seem to figure out the issue on my end, only idea is that it does not comply with AMP.

Any suggestions would be helpful!

Upvotes: 0

Views: 430

Answers (1)

Stefany Newman
Stefany Newman

Reputation: 524

You either have your amp-iframe above the fold without a placeholder or you haven't allowed script execution in the sandbox attribute.

Add this to your amp-iframe element:

sandbox="allow-scripts allow-same-origin allow-popups"

By default, browsers block JS execution in iframes. That's why you must enable it with the sandbox attribute.

Upvotes: 0

Related Questions