Skip to content

Instantly share code, notes, and snippets.

@guytzhak
Created April 28, 2021 10:16
Show Gist options
  • Save guytzhak/d34aaeb8b4e21a44d0d20b4b00ad53d2 to your computer and use it in GitHub Desktop.
Save guytzhak/d34aaeb8b4e21a44d0d20b4b00ad53d2 to your computer and use it in GitHub Desktop.
Iframebymozi
<iframe src="https://iqosiframe.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