Skip to content

Instantly share code, notes, and snippets.

@wok
Last active January 9, 2018 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wok/221478f4ac16f05a7377dee714520a1a to your computer and use it in GitHub Desktop.
Save wok/221478f4ac16f05a7377dee714520a1a to your computer and use it in GitHub Desktop.
(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