Created
July 31, 2013 14:24
-
-
Save teeaich/6122432 to your computer and use it in GitHub Desktop.
get specific iframe with ID
This file contains hidden or 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 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