var iframe = document.createElement('iframe'); iframe.src = 'https://i.vahanjewelry.com/ZQye7L4FrAiu8/collections/vahan-essentials/?collection[]=60&landing'; iframe.scrolling = 'no'; iframe.style.width = '100%'; iframe.style.minHeight = '600px'; iframe.style.border = 'none'; iframe.style.opacity = '0'; document.getElementById('vahan-iframe').appendChild(iframe); var prevHeight = 0; window.addEventListener('message', function(event) { if (typeof event.data !== 'string') { return; } var key = 'vahan-iframe-height:'; if (event.data.indexOf(key) === -1) { return; } var height = parseInt(event.data.substring(key.length)); if (Math.abs(height - prevHeight) <= 30) { return; } height += 30; prevHeight = height; iframe.height = height; iframe.style.height = height + 'px'; iframe.style.opacity = '1'; iframe.style.overflowX = 'hidden'; });