Skip to content

Instantly share code, notes, and snippets.

@guytzhak
Created May 2, 2021 23:57
Show Gist options
  • Save guytzhak/6cef54590cab38a4d218f74d865d9df9 to your computer and use it in GitHub Desktop.
Save guytzhak/6cef54590cab38a4d218f74d865d9df9 to your computer and use it in GitHub Desktop.
<iframe src="https://iqosiframe2.ussl.co/" width="100%" height="200px" style="border: 0; position: fixed; left: 0; bottom: 0; width: 100%; max-height: 100%; transition: 0.15s ease-out height;" class="mozi_iframe"></iframe>
<script>
var eventMethod = window.addEventListener
? "addEventListener"
: "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod === "attachEvent"
? "onmessage"
: "message";
eventer(messageEvent, function (e) {
if( typeof e.data[0] == 'string' && e.data[0] == 'change_height' ) {
document.querySelector('iframe.mozi_iframe').style.height = e.data[1];
} else if( typeof e.message[0] == 'string' && e.message[0] == 'change_height' ) {
document.querySelector('iframe.mozi_iframe').style.height = e.message[1];
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment