Adjust iframe height to avoid scrollbar

This commit is contained in:
2026-07-17 09:40:22 +02:00
parent 7cbcb954b4
commit 73ccac49d7
2 changed files with 22 additions and 2 deletions
+21 -1
View File
@@ -9,4 +9,24 @@
</article>
{% include "partials/components/contact-form.njk" %}
</main>
{% endblock %}
<script>
const iframeContainer = document.querySelector('.simulateur .iframe-container');
const iframe = document.getElementById('simulateurFrame');
const iframeContent = document.getElementById('simulateurFrame').contentWindow;
function setIframeHeight() {
iframe.style.height = iframeContent.document.body.scrollHeight + 'px';
iframeContainer.style.minHeight = iframeContent.document.body.scrollHeight + 'px';
iframeContainer.style.paddingTop = '0';
}
iframe.addEventListener('load', () => {
setIframeHeight();
setTimeout(function() {
setIframeHeight(); // permet de reajuster apres chargement complet au besoin
}, 2000);
});
</script>
{% endblock %}