Adjust iframe height to avoid scrollbar
This commit is contained in:
@@ -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 %}
|
||||
Reference in New Issue
Block a user