{% set src = _args.src %}
{% set htmlId = 'hubspot-frame-%s'|format(
token()
) %}
{% set autoHeight = _args.autoHeight|default(false) %}
{#
This is the snippet needed in the iframe content to make this work:
<script type="text/javascript">$(function() { window.top.postMessage({height: $(document).height()}, '*'); });</script>
#}
{% if autoHeight %}
<script type="text/javascript">
window.addEventListener('message', function (e) {
var frame = $('#{{ htmlId }}')[0],
wndw = frame.contentWindow;
if (e.origin === "https://content.schoolnow.com" && e.source === wndw) {
$(function() {
$('#{{ htmlId }}').css('height', (e.data.height + 40) + 'px');
});
}
});
</script>
{% endif %}
<iframe id="{{ htmlId }}" style="border: none; width: 100%; height: 100%;" src="{{ src }}"></iframe>