October 2017
Intermediate to advanced
370 pages
8h 57m
English
Like all AMP elements, amp-iframe must define its static layout, but it's also possible to resize an amp-iframe at runtime. This is useful if the iframe contains dynamic content that you don't know the size of in advance (we'll see this in the Disqus example later). The resizable attribute can be added to the amp-iframe element to indicate that it can be resized:
<amp-iframe src="" ... resizable ...>
A request can be sent from the iframe to the AMP page container to request a resize. The requested height is specified in the height property. It could simply be a numeric value representing the pixel height, or it could be computed by JavaScript in the iframe code itself, like this, for example:
window.parent.postMessage({ sentinel: ...Read now
Unlock full access