Last active
January 9, 2018 06:47
-
-
Save wok/221478f4ac16f05a7377dee714520a1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
function ready(fn) { | |
if (document.readyState != 'loading') { | |
fn(); | |
} else { | |
document.addEventListener('DOMContentLoaded', fn); | |
} | |
} | |
ready(function() { | |
var elems = document.querySelectorAll('div.myclub-embed'); | |
Array.prototype.forEach.call(elems, setupElement); | |
}); | |
function setupElement(elem) { | |
var url = elem.getAttribute('data-url'); | |
if (url) { | |
var iFrame = document.createElement('iframe'); | |
iFrame.src = url; | |
iFrame.scrolling = 'no'; | |
iFrame.style.border = '0px'; | |
// To counter iOS iframe width bug, | |
// see https://stackoverflow.com/questions/23823615/an-iframe-is-wider-than-it-should-on-iphone | |
iFrame.style.width = '1px'; | |
iFrame.style.minWidth = '100%'; | |
elem.appendChild(iFrame); | |
iFrameResize({ checkOrigin: false }, iFrame); | |
} | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment