jQuery | Communicate with postMessage

<!-- Iframe Container -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var Iframe = jQuery('#iframe');
window.addEventListener('message', function(e) { 
    var eventName = e.data[0]; 
    var data = e.data[1]; 
    switch(eventName) { 
        case 'setHeight': 
            newIframe.height(data); 
        break;
    } 
}, false);
</script>
<iframe id="iframe" src="https://go.domain.com/form.html"></iframe>[/code]


[code language="html" light="true"][/code]<!-- Iframe Content -->
<script>
var StatusResizing = 'on';
setInterval(function() {
    if(StatusResizing == 'on') {
        resize();
    }
}, 1000);
function resize() {
    var height = $('body').outerHeight();
    window.parent.postMessage(["setHeight", height], "*"); 
}</script>
My website may contain fan art inspired by existing characters from movies or tv shows, I dont own any rights. Any copyright owner willing to remove those fan arts can contact me here. This is a personal portfolio, the sole use of cookies are for analysing my traffic through Google Analytics, if you're ok with that please accept this terms by closing this disclaimer.