October 2017
Intermediate to advanced
370 pages
8h 57m
English
We'll need to send a message to the iframe parent in the AMP page so that it's sized correctly based on the amount of comment data there is. We can achieve this with another script:
<script> window.addEventListener('message', receiveMessage, false); function receiveMessage(event) { if (event.data) { var msg; try { msg = JSON.parse(event.data); } catch (err) {} if(!msg) return false; if(msg.name === 'resize') { window.parent.postMessage({ sentinel: 'amp', type: 'embed-size', height: msg.data.height }, '*'); } } }</script>
Read now
Unlock full access