from foo.html, you can get the parent window with parent
; once you're there, you can compare each iframe property contentWindow
with this
- matched with you.
Finding the parent of all iframes is the hardest part of this; it would be easy to quickly write a library like jQuery, but something was quickly hacked:
var mycontainer;
var iframes = document.getElementsByTagName("iframe");
for (var iter = 0; iter <iframes.length; iter++){
if( iframes[iter].contentWindow && iframes[iter].contentWindow === window){
mycontainer = iframes[iter].parentNode;
}
}
a source
to share