Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save teeaich/6122432 to your computer and use it in GitHub Desktop.
get specific iframe with ID
function getFrameForDocument(document,id) {
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 {
if (frame.id===id)
return frame.contentDocument || frame.contentWindow.document;
} catch(e) {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment