Skip to content

Instantly share code, notes, and snippets.

@teeaich
Created July 31, 2013 14:24
Show Gist options
  • Select an option

  • Save teeaich/6122426 to your computer and use it in GitHub Desktop.

Select an option

Save teeaich/6122426 to your computer and use it in GitHub Desktop.
get document of own iframe
function getFrameForDocument(document) {
var w= document.defaultView || document.parentWindow;
var frames= w.parent.document.getElementsByTagName('iframe');
for (var i= frames.length; i-->0;) {
var frame= frames[i];
try {
var d= frame.contentDocument || frame.contentWindow.document;
if (d===document)
return frame;
} catch(e) {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment