Skip to content

Instantly share code, notes, and snippets.

@trnktms
Created April 6, 2017 14:18
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 trnktms/f87b55dbdbd2b6cbe84b8a3fe294ce55 to your computer and use it in GitHub Desktop.
Save trnktms/f87b55dbdbd2b6cbe84b8a3fe294ce55 to your computer and use it in GitHub Desktop.
function fieldBase () {}
fieldBase.getParentIframe = function () {
var iframes = window.parent.document.getElementsByTagName('iframe');
var parent;
Array.prototype.forEach.call(iframes, function (el, i) {
if (fieldBase.getIframeDocument(el) === window.document) {
parent = el;
return;
}
});
return parent;
};
fieldBase.getIframeDocument = function (iframe) {
return iframe.contentDocument || iframe.contentWindow.document;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment